From 4cb84aa1d1a31a016d1a28553ae0e4b68a15e3a3 Mon Sep 17 00:00:00 2001 From: tfheen Date: Tue, 15 Nov 2011 17:05:59 +0000 Subject: [PATCH] misc updates git-svn-id: file:///svn/tfheen/trunk/dotfiles@1494 8da78d58-1cd3-0310-bee5-d77bd1b3e8bf --- emacs | 147 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 143 insertions(+), 4 deletions(-) diff --git a/emacs b/emacs index 7f93e27..1eafb8a 100644 --- a/emacs +++ b/emacs @@ -97,10 +97,10 @@ (cw/requiring-package (w3-auto)) -(setq browse-url-browser-function 'browse-url-mozilla +(setq browse-url-browser-function 'browse-url-generic browse-url-new-window-p t browse-url-mozilla-program (or (executable-find "firefox-3.0") "firefox") - browse-url-generic-program "opera") + browse-url-generic-program "chromium") ;; File modes @@ -109,12 +109,14 @@ (autoload 'pov-mode "pov-mode" "PoVray scene file mode" t) (autoload 'jde-mode "jde" "Java Development Environment" t) (autoload 'dtml-mode "dtml-mode" "Document Template Markup Language" t) +(autoload 'vcl-mode "vcl-mode") (add-to-list 'auto-mode-alist '("\\.php3$" . php-mode)) (add-to-list 'auto-mode-alist '("\\.css$" . css-mode)) (add-to-list 'auto-mode-alist '("\\.pov$" . pov-mode)) (add-to-list 'auto-mode-alist '("\\.jl$" . lisp-mode)) (add-to-list 'auto-mode-alist '("\\.java$" . jde-mode)) +(add-to-list 'auto-mode-alist '("\\.vcl$" . vcl-mode)) ;; Set up autoloading and auto-mode (autoload 'ps-mode "ps-mode" @@ -164,7 +166,7 @@ header-email-address "tollef@err.no" add-log-mailing-address "tfheen@err.no" debian-changelog-mailing-address "tfheen@debian.org" - tags-table-list (list (expand-file-name "~/usr/include/"))) + tags-table-list '("~/varnish" "~/usr/include/")) (setq sgml-local-catalogs (list "~/usr/lib/sgml/sgml.catalog")) @@ -372,7 +374,7 @@ (cw/for-emacs-23-and-later (setq tfheen-base-size 8) - (setq tfheen-base-font "Bitstream Vera Sans Mono" + (setq tfheen-base-font "DejaVu Sans Mono" tfheen-current-size tfheen-base-size) ;; Firefox-like zooming of fonts. @@ -398,6 +400,59 @@ (define-key global-map (read-kbd-macro "C-=") 'font-zoom-reset-font-size) (font-zoom-reset-font-size)) +(defun minutes-to-hours (minutes) + (/ (* 1.0 minutes) 60)) + +(defun weekend-p (time) + (> (string-to-number (format-time-string "%u" time)) 5)) + +(defun org-dblock-write:timebalance (params) + "Display day-by-day summary, giving a balance" + (let* ((ts (plist-get params :tstart)) + (te (plist-get params :tend)) + (ins (make-marker)) + (start (time-to-seconds + (apply 'encode-time (org-parse-time-string ts)))) + (end (time-to-seconds + (apply 'encode-time (org-parse-time-string te)))) + tbl sum) + + (setq params (plist-put params :tstart nil)) + (setq params (plist-put params :end nil)) + (move-marker ins (point)) + (while (<= start end) + (save-excursion + (let ((sum 0)) + (org-clock-sum start (+ start 86400)) + (goto-char (point-min)) + (setq st t) + (while (or (and (bobp) (prog1 st (setq st nil)) + (get-text-property (point) :org-clock-minutes) + (setq p (point-min))) + (setq p (next-single-property-change (point) :org-clock-minutes))) + (goto-char p) + (message (format "pre: %s %d %d %s" (format-time-string "%Y-%m-%d" (seconds-to-time start)) sum start (point))) + (if (= 1 (car (org-heading-components))) + (setq sum (+ sum (or (get-text-property p :org-clock-minutes) 0))))) + (push (list start sum) tbl))) + (setq start (+ 86400 start))) + (setq tbl (nreverse tbl)) + (goto-char ins) + (setq sum 0) + (while tbl + (let* ((line (car tbl)) + (ts (seconds-to-time (first line))) + (minutes (second line)) + (hours (minutes-to-hours minutes))) + (setq sum (+ sum hours)) + (if (not (weekend-p ts)) + (setq sum (- sum 7.5))) + (if (> minutes 0) + (insert-before-markers + (format-time-string "%Y-%m-%d" ts) + (format " %f %f\n" hours sum)))) + (setq tbl (cdr tbl))))) + (defun org-dblock-write:gtimelog (params) "Display day-by-day time reports in gtimelog format." (let* ((ts (plist-get params :tstart)) @@ -478,3 +533,87 @@ ad-do-it (ad-disable-advice 'current-time 'after 'tfheen-ceiling-current-time) (ad-activate 'current-time)) + +(autoload 'vala-mode "vala-mode" "Major mode for editing Vala code." t) +(add-to-list 'auto-mode-alist '("\\.vala$" . vala-mode)) +(add-to-list 'auto-mode-alist '("\\.vapi$" . vala-mode)) +(add-to-list 'file-coding-system-alist '("\\.vala$" . utf-8)) +(add-to-list 'file-coding-system-alist '("\\.vapi$" . utf-8)) + +(cw/for-host "qurzaw" + (require 'twittering-mode)) + +(defun unfill-paragraph () + (interactive) + (let ((fill-column (point-max))) + (fill-paragraph nil))) + +(defun unfill-region () + (interactive) + (let ((fill-column (point-max))) + (fill-region (region-beginning) (region-end) nil))) + +(define-key global-map "\M-Q" 'unfill-paragraph) +(define-key global-map "\C-\M-q" 'unfill-region) + +(setq twittering-use-native-retweet t + twittering-use-icon-storage t + twittering-icon-mode t) + +(setq tfheen-twittering-filter-blacklist + '((text . "#oslo #planking") + (text . "#WEBELIEBE") + (user-screen-name . "\\(Oslo_HitHot\\|Map_Game\\|anbud1\\)"))) + +(defun tfheen-twitter-filter-search () + (interactive) + (let ((non-matching-statuses ())) + (dolist (status twittering-new-tweets-statuses) + (if (eq (cadr (assoc 'source-spec status)) 'search) + (let ((matched-tweets 0)) + (dolist (item tfheen-twittering-filter-blacklist) + (let* ((type (car item)) + (pat (cdr item))) + (if (string-match pat (cdr (assoc type status))) + (setq matched-tweets (+ 1 matched-tweets))))) + (if (= 0 matched-tweets) + (setq non-matching-statuses (append non-matching-statuses `(,status))))) + (setq non-matching-statuses (append non-matching-statuses `(,status))))) + (setq new-statuses non-matching-statuses))) + +(add-hook 'twittering-new-tweets-hook 'tfheen-twitter-filter-search) + +(setq twittering-initial-timeline-spec-string + '(":home" + ":replies" + ":direct_messages" + ":search/#oslo/" + ":search/#varnish/")) + +(define-key org-mode-map [home] 'beginning-of-buffer) +(define-key org-mode-map [end] 'end-of-buffer) + +(defun tfheen/weekday-p () + (let ((wday (nth 6 (decode-time)))) + (and (< wday 6) + (> wday 0)))) + +(defun tfheen/working-p () + (let ((hour (nth 2 (decode-time)))) + (and (tfheen/weekday-p) + (and (>= hour 7) (<= hour 15))))) + +(defun tfheen/org-auto-exclude-function (tag) + "Automatic task exclusion in the agenda with / RET" + (and (cond + ((string= tag "@farm") + t) + (t + (if (tfheen/working-p) + (setq tag "@hjemme") + (setq tag "@jobb")) + (unless (member (concat "-" tag) org-agenda-filter) + tag))) + (concat "-" tag))) + +(setq org-agenda-auto-exclude-function 'tfheen/org-auto-exclude-function) \ No newline at end of file -- 2.39.5