From: Steve Purcell Date: Mon, 30 Dec 2013 10:11:06 +0000 (+0000) Subject: Derive from special-mode X-Git-Tag: v0.1~7 X-Git-Url: http://christophe.rhodes.io/gitweb/?a=commitdiff_plain;h=06c057214ea2f9c4220ecd7d0b49018a9b65e470;p=iplayer-el.git Derive from special-mode - Ensures buffer is read-only, and responds to "q" - Buffer is made temporarily writable while inserting programme tree --- diff --git a/iplayer.el b/iplayer.el index 7e1726b..d61b6d1 100644 --- a/iplayer.el +++ b/iplayer.el @@ -142,16 +142,18 @@ (defun display-iplayer-tree (tree) (with-current-buffer (get-buffer-create "*iplayer*") - (delete-region (point-min) (point-max)) + (let ((buffer-read-only nil)) + (fundamental-mode) + (delete-region (point-min) (point-max)) + (dolist (entry tree) + (let ((program (car entry)) + (episodes (cdr entry))) + (insert (propertize (format "* %s\n" program) 'face 'outline-1)) + (dolist (episode episodes) + (insert (propertize (format "** %s\n" (cdr episode)) + 'face 'outline-2 'iplayer-id (car episode))))))) (iplayer-mode) (orgstruct-mode 1) - (dolist (entry tree) - (let ((program (car entry)) - (episodes (cdr entry))) - (insert (propertize (format "* %s\n" program) 'face 'outline-1)) - (dolist (episode episodes) - (insert (propertize (format "** %s\n" (cdr episode)) - 'face 'outline-2 'iplayer-id (car episode)))))) (org-overview) (goto-char (point-min))) (switch-to-buffer (get-buffer-create "*iplayer*"))) @@ -246,12 +248,9 @@ The presets are defined in the variable `iplayer-presets'." map )) -(defun iplayer-mode () +(define-derived-mode iplayer-mode special-mode "iPlayer" "A major mode for the BBC's iPlayer. -\\{iplayer-mode-map}" - (interactive) - (use-local-map iplayer-mode-map) - (setq major-mode 'iplayer-mode mode-name "iPlayer")) +\\{iplayer-mode-map}") (define-iplayer-command iplayer (&optional keys) "Start the emacs iPlayer interface."