summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Tom Willemsen2011-07-15 19:08:07 +0200
committerGravatar Tom Willemsen2011-07-15 19:08:07 +0200
commit2e3c5df4d78e4c956b070efddea2b4405f717640 (patch)
treeb6cdb28338f66c64401f807d627d40238de9689d
parentce4e353a70ed8425b0c60f4754e0cb4684bc381e (diff)
downloaddotfiles-2e3c5df4d78e4c956b070efddea2b4405f717640.tar.gz
dotfiles-2e3c5df4d78e4c956b070efddea2b4405f717640.zip
EMACS: lots of changes
* Extended ** emacs.d/functions.el - Added a optional ~else~ part to ~foreach~ in HTML keywords, since smarty *can* also use ~foreachelse~, and this was only fontifying the ~foreach~ part. - Only load (and modify) naquadah-theme when we're running in X. I'd prefer to know if we have 256 colors available, but I haven't found that yet. - Only try to go to fullscreen if X is running. - Show a lambda symbol when the word lambda is found in a prog-mode buffer. - Enable auto-fill-mode when prog-mode is started. - Don't set pear options, pi-php-mode does it. - Added function to show ~lambda~ as a lambda symbol - Added function to create or update gtags file. ** emacs.el - Add pi-php-mode. - Removed muttrc-mode. - Use pi-php-mode instead of php-mode-improved. - Use ~(getenv)~ to get the browser. - Don't care about ~org-babel-confirm-evaluate~ and ~org-ditaa-jar-path~. - Set ~org-return-follows-link~ to ~t~, enter follows a link in ~org-mode~. - Set ~mouse-autoselect-window~ to ~t~, moving the mouse changes buffer focus. - Set ~pop-up-windows~ to ~nil~, so that popup functions use an existing window. - Set ~org-log-into-drawer~ to ~t~, so that activities are put in a drawer in ~org-mode~. - Set ~mail-header-separator~ to an empty string for ~message-mode~. - Use ~message-mode~ instead of ~mail-mode~.
-rw-r--r--emacs.d/functions.el51
-rw-r--r--emacs.el161
2 files changed, 141 insertions, 71 deletions
diff --git a/emacs.d/functions.el b/emacs.d/functions.el
index 6d2a5e5..9c8f7da 100644
--- a/emacs.d/functions.el
+++ b/emacs.d/functions.el
@@ -74,7 +74,7 @@ Currently adds | & ! . + = - / % * , < > ? : ->"
(font-lock-add-keywords
'html-mode
'(("{\\(\\*.*\\*\\)}" 1 font-comment-face)
- ("{\\/?\\(extends\\|block\\|foreach\\|if\\)"
+ ("{\\/?\\(extends\\|block\\|foreach\\(else\\)?\\|if\\)"
1 font-lock-builtin-face)
("\\$\\(\\(?:\\sw\\|\\s_\\)+\\)\\(?:|\\(\\(?:\\sw\\|\\s_\\)+\\):\\)"
(1 font-lock-variable-name-face)
@@ -121,7 +121,24 @@ Currently adds | & ! . + = - / % * , < > ? : ->"
(insert-char ?\; width))
(defun x-init ()
- "Start ide-skel and set some keys")
+ "Initialization only for X"
+ (require 'naquadah-theme)
+ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+ ;; THEME SETTINGS ;;
+ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+ (naquadah-theme-set-faces
+ 'naquadah
+
+ ;; markdown-mode
+ '(markdown-link-face (:inherit 'link))
+ '(markdown-header-face-1 (:inherit 'org-level-1))
+ '(markdown-header-face-2 (:inherit 'org-level-2))
+ '(markdown-header-face-3 (:inherit 'org-level-3))
+ '(markdown-header-face-4 (:inherit 'org-level-4))
+ '(markdown-header-face-5 (:inherit 'org-level-5))
+ '(markdown-header-face-6 (:inherit 'org-level-6)))
+
+ (add-hook 'emacs-startup-hook 'fullscreen))
(defun cli-init ()
"Add a space to the linum column"
@@ -156,7 +173,9 @@ Currently adds | & ! . + = - / % * , < > ? : ->"
("\\b\\(\\.[0-9]+\\([eE][-+]?[0-9]+\\)?\\([lL]\\|[fF]\\|[dD]\\)?\\)\\b"
0 font-lock-constant-face)))
(set-column-marker)
- (rainbow-delimiters-mode))
+ (rainbow-delimiters-mode)
+ (pretty-lambdas)
+ (auto-fill-mode 1))
(defun on-c-mode ()
(local-set-key [f8] 'c-toggle-header-source)
@@ -178,10 +197,6 @@ Currently adds | & ! . + = - / % * , < > ? : ->"
(auto-fill-mode 1))
(defun on-php-mode ()
- (defvar php-warn-if-mumamo-off nil)
- (setq case-fold-search t)
- (c-set-offset 'arglist-intro '+)
- (c-set-offset 'arglist-close '0)
(column-marker-1 76)
(column-marker-2 81)
(local-set-key [f6] 'comment-line))
@@ -189,3 +204,25 @@ Currently adds | & ! . + = - / % * , < > ? : ->"
(defun on-mail-mode ()
(turn-on-auto-fill)
(search-forward "\n\n"))
+
+(defun pretty-lambdas ()
+ (font-lock-add-keywords
+ nil `(("(\\(lambda\\>\\)"
+ (0 (progn
+ (compose-region (match-beginning 1)
+ (match-end 1)
+ ?λ)))))))
+
+;; http://emacs-fu.blogspot.com/2009/01/navigating-through-source-code-using.html
+(defun djcb-gtags-create-or-update ()
+ "create or update the gnu global tag file"
+ (interactive)
+ (if (not (= 0 (call-process "global" nil nil nil " -p"))) ; tagfile
+ (let ((olddir default-directory) ; doesn't exist?
+ (topdir (read-directory-name
+ "gtags: top of source tree:" default-directory)))
+ (cd topdir)
+ (shell-command "gtags && echo 'created tagfile'")
+ (cd olddir)) ; restore
+ ;; tagfile already exists; update it
+ (shell-command "global -u && echo 'updated tagfile'")))
diff --git a/emacs.el b/emacs.el
index ef5ceb2..06ab322 100644
--- a/emacs.el
+++ b/emacs.el
@@ -7,11 +7,11 @@
(add-to-list 'load-path "~/.emacs.d/elisp/markdown-mode")
(add-to-list 'load-path "~/.emacs.d/elisp/git-commit-mode")
(add-to-list 'load-path "~/.emacs.d/elisp/lua-mode")
+(add-to-list 'load-path "~/.emacs.d/elisp/pi-php-mode")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; REQUIRES ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-(require 'naquadah-theme)
(require 'autopair)
(require 'column-marker)
(require 'git-commit)
@@ -21,7 +21,6 @@
(require 'server)
(require 'org-publish)
(require 'htmlize)
-(require 'muttrc-mode)
(load-file "~/.emacs.d/functions.el")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -32,7 +31,7 @@
(autoload 'sqlplus-mode "sqlplus" "Major mode for PL/SQL" t)
(autoload 'batch-mode "batch-mode" "Major mode for Batch" t)
(autoload 'lua-mode "lua-mode" "A Major mode for Lua" t)
-(autoload 'php-mode "php-mode-improved" "Major mode for PHP" t)
+(autoload 'php-mode "pi-php-mode" "Major mode for PHP" t)
(autoload 'graphviz-dot-mode "graphviz-dot-mode" "Major mode for dot" t)
(autoload 'cmake-mode "cmake-mode" "Major mode for CMake" t)
(autoload 'markdown-mode "markdown-mode" "Major mode for Markdown" t)
@@ -57,57 +56,6 @@
(setup-system-frame-colours))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; FILE ASSOCIATIONS ;;
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-(add-to-list 'auto-mode-alist '("\\.vala$" . vala-mode))
-(add-to-list 'auto-mode-alist '("\\.vapi$" . vala-mode))
-(add-to-list 'auto-mode-alist '("\\.cs$" . csharp-mode))
-(add-to-list 'auto-mode-alist '("\\.bat$" . batch-mode))
-(add-to-list 'auto-mode-alist '("\\.lua$" . lua-mode))
-(add-to-list 'auto-mode-alist '("\\.php[345]?$" . php-mode))
-(add-to-list 'auto-mode-alist '("\\.js\\(on\\)?$" . js-mode))
-(add-to-list 'auto-mode-alist '("\\.m\\(ark\\)?do?wn$". markdown-mode))
-(add-to-list 'auto-mode-alist '("CMakeLists\\.txt$" . cmake-mode))
-(add-to-list 'auto-mode-alist '("\\.cmake$" . cmake-mode))
-(add-to-list 'auto-mode-alist '("\\.css$" . css-mode))
-(add-to-list 'auto-mode-alist '("mutt-cloud-" . mail-mode))
-(add-to-list 'auto-mode-alist '("stumpwmrc" . stumpwm-mode))
-(add-to-list 'auto-mode-alist '("\\.go$" . go-mode))
-
-(add-to-list 'file-coding-system-alist '("\\.vala$" . utf-8))
-(add-to-list 'file-coding-system-alist '("\\.vapi$" . utf-8))
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; KEYBINDS ;;
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-(global-set-key "\C-m" 'newline-and-indent)
-(global-set-key (kbd "C-x n r") 'narrow-to-region)
-(global-set-key "\C-cl" 'org-store-link)
-(global-set-key "\C-cc" 'org-capture)
-(global-set-key "\C-ca" 'org-agenda)
-(global-set-key [f5] '(lambda ()
- (interactive)
- (revert-buffer nil t nil)))
-(global-set-key [M-left] 'windmove-left)
-(global-set-key [M-right] 'windmove-right)
-(global-set-key [M-up] 'windmove-up)
-(global-set-key [M-down] 'windmove-down)
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; THEME SETTINGS ;;
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-(naquadah-theme-set-faces
- 'naquadah
-
- ;; markdown-mode
- '(markdown-link-face (:inherit 'link))
- '(markdown-header-face-1 (:inherit 'org-level-1))
- '(markdown-header-face-2 (:inherit 'org-level-2))
- '(markdown-header-face-3 (:inherit 'org-level-3))
- '(markdown-header-face-4 (:inherit 'org-level-4))
- '(markdown-header-face-5 (:inherit 'org-level-5))
- '(markdown-header-face-6 (:inherit 'org-level-6)))
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; SETTINGS ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(setq-default indent-tabs-mode nil) ; spaces, no tabs
@@ -119,20 +67,23 @@
(setq inhibit-default-init t) ; Don't load default library
(setq scroll-conservatively 101) ; scroll only one line
(setq browse-url-browser-function 'browse-url-generic)
-(setq browse-url-generic-program "$BROWSER")
+(setq browse-url-generic-program (getenv "BROWSER"))
(setq whitespace-style '(face trailing)) ; For use with markdown mode
(setq uniquify-buffer-name-style 'reverse)
-(setq org-confirm-babel-evaluate nil)
(setq org-tags-exclude-from-inheritance '("crypt"))
(setq org-crypt-key "33E8CC1CC4")
(setq org-use-fast-todo-selection t)
(setq org-default-notes-file (concat org-directory "/notes.org"))
-(setq org-ditaa-jar-path "/usr/share/java/ditaa/ditaa-0_9.jar")
(setq jit-lock-defer-time 0.2) ; Don't fontlock immediately
(setq htmlize-output-type 'inline-css)
(setq ido-save-directory-list-file nil)
(setq ido-auto-merge-delay-time 2) ; Wait before fixing names
(setq org-outline-path-complete-in-steps t)
+(setq org-return-follows-link t)
+(setq mouse-autoselect-window t)
+(setq pop-up-windows nil)
+(setq org-log-into-drawer t)
+(setq mail-header-separator "")
(setq frame-title-format ; I don't like emacs@cloud, must have file
'(:eval ; name
@@ -155,9 +106,6 @@
"DONE(d!/!)"
"CANCELLED(c@/!)")))
-(setq org-babel-load-languages
- '((ditaa . t)))
-
(setq org-refile-targets
'((org-agenda-files :maxlevel . 5)
(nil :maxlevel . 5)))
@@ -190,6 +138,44 @@
(add-to-list 'compilation-finish-functions 'my-comp-finish-function)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; FILE ASSOCIATIONS ;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+(add-to-list 'auto-mode-alist '("\\.vala$" . vala-mode))
+(add-to-list 'auto-mode-alist '("\\.vapi$" . vala-mode))
+(add-to-list 'auto-mode-alist '("\\.cs$" . csharp-mode))
+(add-to-list 'auto-mode-alist '("\\.bat$" . batch-mode))
+(add-to-list 'auto-mode-alist '("\\.lua$" . lua-mode))
+(add-to-list 'auto-mode-alist '("\\.php[345]?$" . php-mode))
+(add-to-list 'auto-mode-alist '("\\.js\\(on\\)?$" . js-mode))
+(add-to-list 'auto-mode-alist '("\\.m\\(ark\\)?do?wn$". markdown-mode))
+(add-to-list 'auto-mode-alist '("CMakeLists\\.txt$" . cmake-mode))
+(add-to-list 'auto-mode-alist '("\\.cmake$" . cmake-mode))
+(add-to-list 'auto-mode-alist '("\\.css$" . css-mode))
+(add-to-list 'auto-mode-alist '("stumpwmrc" . stumpwm-mode))
+(add-to-list 'auto-mode-alist '("\\.go$" . go-mode))
+(add-to-list 'auto-mode-alist '("\\.commitmsg$" . org-mode))
+(add-to-list 'auto-mode-alist '(".*mutt.*" . message-mode))
+
+(add-to-list 'file-coding-system-alist '("\\.vala$" . utf-8))
+(add-to-list 'file-coding-system-alist '("\\.vapi$" . utf-8))
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; KEYBINDS ;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+(global-set-key "\C-m" 'newline-and-indent)
+(global-set-key (kbd "C-x n r") 'narrow-to-region)
+(global-set-key "\C-cl" 'org-store-link)
+(global-set-key "\C-cc" 'org-capture)
+(global-set-key "\C-ca" 'org-agenda)
+(global-set-key [f5] '(lambda ()
+ (interactive)
+ (revert-buffer nil t nil)))
+(global-set-key [M-left] 'windmove-left)
+(global-set-key [M-right] 'windmove-right)
+(global-set-key [M-up] 'windmove-up)
+(global-set-key [M-down] 'windmove-down)
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; HOOKS ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(add-hook 'before-save-hook 'on-before-save)
@@ -200,12 +186,24 @@
(add-hook 'markdown-mode-hook 'on-markdown-mode)
(add-hook 'org-mode-hook 'on-org-mode)
(add-hook 'php-mode-hook 'on-php-mode)
-(add-hook 'mail-mode-hook 'on-mail-mode)
+(add-hook 'message-mode-hook 'on-mail-mode)
(add-hook 'git-commit-mode-hook 'auto-fill-mode)
-(add-hook 'emacs-startup-hook 'fullscreen)
(add-hook 'css-mode-hook 'rainbow-mode)
(add-hook 'after-make-frame-functions 'setup-system-frame-colours t)
+(add-hook 'gtags-mode-hook
+ (lambda ()
+ (local-set-key (kbd "M-,") 'gtags-find-tag) ; find a tag,
+ ; also M-.
+ (local-set-key (kbd "M-.") 'gtags-find-rtag))) ; reverse
+ ; tag
+
+(add-hook 'c-mode-common-hook
+ (lambda ()
+ (require 'gtags)
+ (gtags-mode t)
+ (djcb-gtags-create-or-update)))
+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; SKELETONS ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -253,6 +251,41 @@
" characters */"
'(fill-paragraph))
+(define-skeleton myaethon-simple-entity
+ "A basic database entity"
+ ""
+ '(setq name (skeleton-read "Name: "))
+ "<?php\n"
+ "require_once('classes/dbobject.php');\n"
+ "\n"
+ "/* Entity for the " (downcase name) " table */\n"
+ "class " name " extends DB_Object\n"
+ "{\n"
+ "/* Table to select data from */\n"
+ "protected static $tables = '" (downcase name) "';\n"
+ "\n"
+ "/* Get the name of this class\n"
+ "--\n"
+ "ret: __CLASS__ */\n"
+ "protected static function get_class_name()\n"
+ "{\n"
+ "return __CLASS__;\n"
+ "}\n"
+ "\n"
+ "public function update()\n"
+ "{\n"
+ "throw new Exception('Not Implemented.');\n"
+ "}\n"
+ "\n"
+ "public function insert()\n"
+ "{\n"
+ "throw new Exception('Not Implemented.');\n"
+ "}\n"
+ "}\n"
+ "\n"
+ "?>\n"
+ '(indent-region (point-min) (point-max)))
+
(org-crypt-use-before-save-magic)
(ad-activate 'server-create-window-system-frame)
(add-php-keywords)
@@ -267,8 +300,8 @@
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
- '(org-agenda-files (quote ("~/documents/org/main.org")))
- '(safe-local-variable-values (quote ((Mode . shell-script) (ispell-local-dictionary . nl)))))
+ '(org-agenda-files (quote ("~/documents/work/aethon/aethon.org" "~/org/notes.org" "~/development/projects/aethon/myaethon/README.org" "~/documents/org/main.org")))
+ '(safe-local-variable-values (quote ((ispell-dictionary . "nl") (ispell-dictionary . nl) (Mode . shell-script) (ispell-local-dictionary . nl)))))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.