From 04251dd4e270cb43f1c566b2edcd2dc1762b4ae8 Mon Sep 17 00:00:00 2001 From: Alexander Sulfrian Date: Mon, 14 Apr 2014 19:28:26 +0200 Subject: emacs: add foldingo mode --- emacs | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 58 insertions(+), 10 deletions(-) (limited to 'emacs') diff --git a/emacs b/emacs index 7056587..58bb2ab 100644 --- a/emacs +++ b/emacs @@ -1,10 +1,11 @@ -;; -*- self-compile-mode: t -*- +;; -*- self-compile-mode: t; foldingo-close: t -*- (setq custom-file "~/.emacs.d/emacs-custom.el") (load custom-file) (setq warning-suppress-types nil) -;; load-path anpassen +;;{{{ load-path anpassen + (let* ((my-lisp-dir "~/.emacs.d/lisp") (default-directory my-lisp-dir) (orig-load-path load-path)) @@ -12,20 +13,27 @@ (normal-top-level-add-subdirs-to-load-path) (nconc load-path orig-load-path)) -;; fix scroll bug with emacs 24.1 +;;}}} + +;;{{{ fix scroll bug with emacs 24.1 + (when (boundp 'bidi-paragraph-direction) (setq-default bidi-paragraph-direction 'left-to-right)) -;; load own color theme +;;}}} + +;;{{{ load own color theme (when (require 'color-theme nil 'noerror) (color-theme-initialize) (if (not window-system) (color-theme-alex-console) (color-theme-alex))) +;;}}} -;; user settings +;;{{{ user settings (setq user-full-name "Alexander Sulfrian" user-mail-address "alexander@sulfrian.net") +;;}}} ;; define F1 to display man page of the current word (global-set-key [(f1)] (lambda () (interactive) (manual-entry (current-word)))) @@ -45,7 +53,7 @@ (global-set-key [mouse-3] 'imenu) -;; fix keys for urxvt +;;{{{ fix keys for urxvt (if (not window-system) (mapc (lambda (map) (define-key function-key-map @@ -73,6 +81,7 @@ ("" "ESC M-[ c") ("" "ESC M-[ d") ))) +;;}}} (setq auto-mode-alist (cons '("README" . text-mode) auto-mode-alist)) (setq compilation-scroll-output t) @@ -363,7 +372,8 @@ If this is set during find-file, flyspell mode gets enabled automaticaly.") (add-hook 'js-mode-hook (lambda () (flymake-mode t)))) -;; org-mode +;;{{{ org-mode + (when (require 'org nil 'noerror) (progn (setq org-todo-keywords @@ -376,6 +386,8 @@ If this is set during find-file, flyspell mode gets enabled automaticaly.") (setq org-startup-folded 'content) (setq org-startup-indented t))) +;;}}} + ;; promela-mode (when (require 'promela-mode nil 'noerror) (setq auto-mode-alist @@ -408,19 +420,20 @@ If this is set during find-file, flyspell mode gets enabled automaticaly.") ;; arduino-mode (require 'arduino-mode nil 'noerror) -;; deft +;;{{{ deft (when (require 'deft nil 'noerror) (setq deft-extension "org" deft-directory "~/.org/deft/" deft-text-mode 'org-mode) (global-set-key (kbd "") 'deft)) +;;}}} ;; edit with emacs (when (require 'edit-server nil 'noerror) (setq edit-server-new-frame nil) (edit-server-start)) -;; fix raise-frame +;;{{{ fix raise-frame (defadvice raise-frame (after make-it-work (&optional frame) activate) "Work around some bug? in raise-frame/Emacs/GTK/Metacity/something. Katsumi Yamaoka posted this in @@ -428,8 +441,10 @@ If this is set during find-file, flyspell mode gets enabled automaticaly.") (call-process "wmctrl" nil nil nil "-i" "-R" (frame-parameter (or frame (selected-frame)) 'outer-window-id))) +;;}}} + +;;{{{ quick open shell -;; quick open shell (defun dirname (file) (replace-regexp-in-string "[^/]*$" "" file)) @@ -443,3 +458,36 @@ If this is set during find-file, flyspell mode gets enabled automaticaly.") (message "Buffer does not contain a file."))) (global-set-key (kbd "") 'open-buffer-shell) + +;;}}} + +;;{{{ foldingo-mode +(when (require 'foldingo nil 'noerror) + (add-hook 'find-file-hooks + 'install-fold-mode-if-needed) + + ;; we want never implicit foldings + (defun alex-fold-mode-hook () + (setq-default fold-implicit-fold-threshold 1000000)) + (add-hook 'fold-mode-hook + 'alex-fold-mode-hook) + + ;; close all folds when requested with file local variable folding-close + (defadvice install-fold-mode-if-needed (after alex-foldingo-fold-all compile activate) + (if (and fold-mode foldingo-close) + (fold-close-all-folds))) + + ;; shortcut for toggling a fold + (defun alex-fold-toggle-current-fold () + (interactive) + (fold-toggle (fold-current-fold))) + (define-key fold-keymap (kbd "C-c C-f") 'alex-fold-toggle-current-fold) + + ;; refresh the folds after save, but do not change the current status + (defun alex-fold-refresh-after-save () + (when fold-mode + (if foldingo-close + (fold-enter-fold-mode-close-all-folds) + (fold-enter-mode)))) + (add-hook 'after-save-hook 'alex-fold-refresh-after-save)) +;;}}} -- cgit v1.2.3