Permalink
Browse files

checked in the basic themes and some fixes

  • Loading branch information...
1 parent e6d18fa commit 7583502625367f495fe24f2e6e1dcefecd5eecc5 @jave committed Mar 13, 2011
Showing with 157 additions and 19 deletions.
  1. +18 −4 README.org
  2. +8 −0 zen-1-theme.el
  3. +13 −0 zen-2-theme.el
  4. +13 −0 zen-3-theme.el
  5. +96 −15 zen-mode.el
  6. +9 −0 zen-test-theme.el
View
22 README.org
@@ -43,19 +43,26 @@ enable-theme
custom-theme-load-path
customize-create-theme
`:set SETFUNCTION'
+custom-theme-visit-theme
although one could have any number of zen-states, I want a couple of
usable defaults.
**** zen-master
+3
Zen-master mode, like writeroom mode.
-it turns all distractions off, including minibuffer.
-**** zen
+it turns all distractions off, including modeline.
+ (setq mode-line-format nil)
+ (setq-default mode-line-format nil)
+**** zen-deep
+2
no menubor toolbar or scrollbar. fullscreen
**** zen-light
+1
maximized
-**** unzen
- all zen-ness is disabled
+**** zen-wordly
+0
+ all zen-ness is disabled.
*** TODO forbidden URLs
polipoli is a webproxy which has a forbiddenurls feature, which is a
file with regexps of forbidden urls. zen can handle this with
@@ -65,6 +72,13 @@ generated and the file reloaded.
each url shall have a zen state. This could possibly be managed as a
theme variable.
+a problem is that the configuration and reload requires root
+privileges on Fedora(and thus probably many other distributions also)
+
+/etc/polipo/forbidden
+pgrep polipo|xargs kill -SIGUSR1
+service polipo reload
+
*** TODO advice some modes like ERC so as not to
interrupt while in Zen, also dont Gnus while in Zen. You are
supposed to concentrate :)
View
8 zen-1-theme.el
@@ -0,0 +1,8 @@
+(deftheme zen-1
+ "Created 2011-03-10.")
+
+(custom-theme-set-variables
+ 'zen-1
+ '(zen-fullscreen-mode t))
+
+(provide-theme 'zen-1)
View
13 zen-2-theme.el
@@ -0,0 +1,13 @@
+(deftheme zen-2
+ "Created 2011-03-10.")
+
+(custom-theme-set-variables
+ 'zen-2
+ '(scroll-bar-mode nil)
+ '(zen-fullscreen-mode t)
+ '(zen-encumbered-urls (quote ( "#brief timewastes" "www.penny-arcade.com" "www.dilbert.com" "www.xkcd.com" "www.userfriendly.org" "#news waste" "slashdot.org" "dn.se" "#social timewastes" "https://www.facebook.com")))
+ '(menu-bar-mode nil)
+ '(tool-bar-mode nil)
+ '(mode-line-format nil))
+
+(provide-theme 'zen-2)
View
13 zen-3-theme.el
@@ -0,0 +1,13 @@
+(deftheme zen-3
+ "Created 2011-03-10.")
+
+(custom-theme-set-variables
+ 'zen-3
+ '(scroll-bar-mode nil)
+ '(zen-fullscreen-mode t)
+ '(zen-encumbered-urls (quote ( "#brief timewastes" "www.penny-arcade.com" "www.dilbert.com" "www.xkcd.com" "www.userfriendly.org" "#news waste" "slashdot.org" "dn.se" "#social timewastes" "https://www.facebook.com")))
+ '(menu-bar-mode nil)
+ '(tool-bar-mode nil)
+ '(mode-line-format nil))
+
+(provide-theme 'zen-3)
View
111 zen-mode.el
@@ -17,10 +17,9 @@
(provide 'zen-mode)
-(defvar zen-mode-is-active-p nil "If zen mode is currently active
-or not.")
-(defvar zen-mode-previous-state nil "The state of features to be
-disabled in zen-mode, before entering zen-mode.")
+(defvar zen-mode-is-active-p nil "If zen mode is currently active or not.")
+(defvar zen-mode-previous-state nil
+ "The state of features to be disabled in `zen-mode', before entering `zen-mode'.")
(defgroup zen-mode nil "zen-mode"); :group 'some-apropriate-root-group)
@@ -35,8 +34,9 @@ to their previous settings when leaving Zen."
(const menu-bar-mode)
(const tool-bar-mode)
(const frame-mode) ;frame-mode is the inverse of fullscreen, for consistency
- )
- )
+ ))
+
+
(defun zen-mode-get-feature-state (feature)
@@ -51,10 +51,11 @@ FEATURE is a symbol from 'zen-mode-what-is-not-zen'."
tool-bar-mode)
((eq feature 'frame-mode)
(if (eq 'fullboth (frame-parameter nil 'fullscreen)) nil t))
+
;emacs seems to assume a maximized window is also "fullboth".
;zen-mode needs to make a difference between fullscreen and maximized
- )
- )
+ ))
+
(defun zen-mode-set-feature-state (feature state)
"Set zen FEATURE to STATE."
@@ -68,12 +69,12 @@ FEATURE is a symbol from 'zen-mode-what-is-not-zen'."
((eq feature 'tool-bar-mode)
(tool-bar-mode modeflag))
((eq feature 'frame-mode)
- (zen-frame-mode state))
- ))
-)
+ (zen-frame-mode state)))))
+
+
(defun zen-frame-mode (state)
- ;;(message "zen-frame-mode :>>%s<<" state)
+ "STATE set fullscreen."
(cond
;;fullscreen seems to be quirky in some emacsen, this is a feeble workaround
(state (set-frame-parameter nil 'fullscreen 'fullboth-bug)
@@ -82,6 +83,7 @@ FEATURE is a symbol from 'zen-mode-what-is-not-zen'."
(set-frame-parameter nil 'fullscreen 'fullboth))))
+
(defun zen-mode-store-state ()
"Store the state of all features zen is interested in."
(setq zen-mode-previous-state nil)
@@ -109,11 +111,11 @@ FEATURE is a symbol from 'zen-mode-what-is-not-zen'."
((f zen-mode-previous-state))
(while f
(zen-mode-set-feature-state (caar f) (cadar f))
- (setq f (cdr f))))
- )
+ (setq f (cdr f)))))
+
(defun zen-mode-hard-unzen ()
- "hard reset"
+ "Hard reset."
(zen-mode-set-feature-state 'scroll-bar-mode t)
(zen-mode-set-feature-state 'menu-bar-mode t)
(zen-mode-set-feature-state 'tool-bar-mode t)
@@ -138,6 +140,85 @@ FEATURE is a symbol from 'zen-mode-what-is-not-zen'."
(zen-mode-store-state)
(zen-mode-disable-nonzen-features))))
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; zen2 will use emacs custom themes
+;; the theme code is not reliable yet
+;; the old and new zen coexist for the time being
+
+(defvar zen-state nil
+ "Current zen state. nil means no zen. other states correspond to a theme.")
+
+
+
+(defun zen-set-fullscreen (name state)
+ "Customize setter for fullscreen. NAME and STATE from customize."
+ (message "zen-set-fullscreen :>>%s<<" state)
+ (setq zen-fullscreen-mode state)
+ (cond
+ ;;fullscreen seems to be quirky in some emacsen, this is a feeble workaround
+ (state (set-frame-parameter nil 'fullscreen 'fullboth))
+ (t (set-frame-parameter nil 'fullscreen 'fullboth-bug)
+ (set-frame-parameter nil 'fullscreen 'nil))))
+
+(defcustom zen-fullscreen-mode
+ nil "Make frame fullscreen."
+ :group 'zen-mode
+ :set 'zen-set-fullscreen)
+
+(defcustom zen-encumber-file "/etc/polipo/forbidden/zen-forbidden"
+ "File to store encumberings. needs to be writable."
+ :group 'zen-mode
+ :type '(string))
+
+
+(defun zen-set-encumber-urls (name encumber)
+ "Customize setter for encumber urls. NAME and ENCUMBER from customize."
+ (setq zen-encumbered-urls encumber)
+ (zen-make-encumber-file)
+ (zen-polipo-reload))
+
+(defun zen-make-encumber-file ()
+ "Make the file with encumbered urls for Polipo."
+ (with-temp-file zen-encumber-file
+ (insert (mapconcat (lambda (x) x) zen-encumbered-urls "\n"))))
+
+
+(defcustom zen-polipo-reload-command "curl -m 15 -d 'init-forbidden=Read%20forbidden%20file' http://localhost:8123/polipo/status?"
+ "Command for reloading polipo forbidden file."
+ :group 'zen-mode)
+
+(defun zen-polipo-reload ()
+ "Signal reload to polipo."
+ ;;http://localhost:8123/polipo/status?
+ ;; post: init-forbidden Read forbidden file
+ ;; there isnt any convenient POST support in emacs so use curl
+ ;;it appears the curl call can hang because polipo can get into a bad state when the network connection changes
+ ;;so theres a 15 sec timeout by default
+ (call-process-shell-command zen-polipo-reload-command))
+
+
+(defcustom zen-encumbered-urls nil
+ "Make it harder to reach urls so you remember not to go there."
+ :group 'zen-mode
+ :type '(repeat string)
+ :set 'zen-set-encumber-urls)
+
+
+
+(defun zen-state-theme (state)
+ "Theme corresponding to zen STATE."
+ (intern (format "zen-%d" state)))
+
+(defun zen-set-state (state)
+ "Which zen STATE to enter."
+ (interactive "Nzen:")
+ (if (equal 0 state) (setq state nil))
+ ;;nil or 0 means a wordly state.
+ ;;other states are themes
+ (if zen-state (disable-theme (zen-state-theme zen-state)))
+ (if state (enable-theme (zen-state-theme state)))
+ (setq zen-state state))
+
(provide 'zen-mode)
;;; zen-mode.el ends here
View
9 zen-test-theme.el
@@ -0,0 +1,9 @@
+(deftheme zen-test
+ "Created 2011-03-10.")
+
+(custom-theme-set-variables
+ 'zen-test
+ '(zen-encumbered-urls (quote ( "#brief timewastes" "www.penny-arcade.com" "www.dilbert.com" "www.xkcd.com" "www.userfriendly.org" "#news waste" "slashdot.org" "dn.se" "#social timewastes" "https://www.facebook.com")))
+)
+
+(provide-theme 'zen-test)

0 comments on commit 7583502

Please sign in to comment.