Advertisement
tniemi

Emacs settings for Word Processing

Oct 22nd, 2012
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lisp 6.90 KB | None | 0 0
  1. ;;;
  2. ;;; Emacs settings for Word Processing by tero.niemi(a)nimbus.fi
  3. ;;;
  4.  
  5. ;;; General settings:
  6.  
  7. (add-to-list 'load-path (expand-file-name "~/.emacs.d/elisp"))  ; Add local directory to load-path.
  8. (setq frame-title-format "%b %+%+ %f")              ; Window title.
  9. (setq inhibit-startup-message 1)                ; Disable splash screen.
  10. (setq display-time-24hr-format 1)               ; Use 24 hour clock.
  11. (cua-mode 1)                            ; Windows-like keyboard shortcuts.
  12.  
  13. ;;; Additional keys:
  14.  
  15. (global-set-key (kbd "C-f") 'isearch-forward)           ; [Ctrl F] Windows-like find. (Was previously 'forward-char', same as right arrow.)
  16. (global-set-key (kbd "C-s") 'save-buffer)           ; [Ctrl S] Windows-like save. (Was previously 'isearch-forward', same as [Ctrl F].)
  17. (global-set-key (kbd "<M-f4>") 'save-buffers-kill-terminal)         ; Windows-like [Alt F4]
  18. (global-set-key (kbd "<home>") 'beginning-of-visual-line)           ; Windows-like [Home] key
  19. (global-set-key (kbd "C-M--") (lambda () (interactive) (ucs-insert #x2014)))    ; [Ctrl Meta -] EM DASH
  20. (global-set-key (kbd "<Scroll_Lock>") 'scroll-lock-mode)            ; Traditional [Scroll Lock]
  21.  
  22. ;;; Simple Semi-Windows-like redo:
  23.  
  24. ;(require 'cl)
  25. ;(setf (global-key-binding (kbd "C-y")) (kbd "<right> C-z"))    ; [Ctrl Y] Redo last undo/redo. (Was previously 'cua-paste', same as [Ctrl V].)
  26.                                 ; This redo is simple but quite non-perfect.
  27.                                 ; For a better alternative install 'undo-tree.el',
  28.                                 ; or use the emacs style shortcut [Ctrl G][Ctrl Z][Ctrl Z]...
  29. ;;; Windows-like vertical scrolling:
  30.  
  31. (setq scroll-step 1)                        ; Scroll only 1 row at time.
  32. (setq scroll-conservatively 1000000)                ; Do not jump ahead.
  33. (setq scroll-up-aggressively 0)                 ; Do no jump back.
  34. (setq scroll-down-aggressively 0)               ; Do not jump ahead.
  35. (setq auto-window-vscroll nil)                  ; Do not jump on big objects.
  36. (setq scroll-preserve-screen-position t)            ; Preserve cursor position on page-up and page-down.
  37.  
  38. ;;; How near window edge cursor can come? Choose the preferred style:
  39.  
  40. (setq scroll-margin 100)                    ; Keep margin between cursor and window edge.
  41.  
  42. ;; or, alternatively:
  43.  
  44. ;(setq scroll-margin 0)                     ; Windows-like behaviour
  45.  
  46. ;;; X11 specific settings:
  47.  
  48. (when (eq window-system 'x)
  49.  
  50.   ;;; [Ctrl -] [Ctrl +] [Ctrl 0] Change font size:
  51.  
  52.   (setq text-scale-mode-step 1.05)
  53.   (global-set-key (kbd "C-+") 'text-scale-increase)
  54.   (global-set-key (kbd "C--") 'text-scale-decrease)
  55.   (global-set-key (kbd "C-0") (lambda () (interactive) (text-scale-increase 0)))
  56.  
  57.   ;;; Appearance:
  58.  
  59.   (set-default 'cursor-type '(bar . 2))             ; Cursor is 2 pixel wide vertical bar
  60.   (set-face-attribute 'italic nil :italic t :underline nil) ; Use real italics instead of underlining
  61.  
  62.   ;;; Colors:
  63.  
  64.   (setq   background-color "#374763")
  65.   (setq   foreground-color "#FFFFFF")
  66.   (setq   minibuffer-color "#95A2B9")
  67.   (setq    selection-color "#7887A3")
  68.   (setq mode-line-bg-color "#DCDCDC")
  69.   (setq mode-line-fg-color "#222222")
  70.   (set-face-attribute 'default           nil :background   background-color :foreground   foreground-color)
  71.   (set-face-attribute 'fringe            nil :background   background-color :foreground   foreground-color)
  72.   (set-face-attribute 'minibuffer-prompt nil                                :foreground   minibuffer-color)
  73.   (set-face-attribute 'region            nil :background    selection-color                               )
  74.   (set-face-attribute 'mode-line         nil :background mode-line-bg-color :foreground mode-line-fg-color)
  75.   (set-cursor-color minibuffer-color)
  76.  
  77.   ;;; [F11] Fullscreen mode:
  78.  
  79.   (defun toggle-fullscreen ()
  80.          "Toggle full screen on X11"
  81.          (interactive)
  82.          (if (frame-parameter nil 'fullscreen)
  83.              (progn
  84.                (set-frame-parameter nil 'fullscreen nil)
  85.                (menu-bar-mode 1)
  86.                (tool-bar-mode 1)
  87.                (scroll-bar-mode 1)
  88.                (set-face-attribute 'mode-line nil :background mode-line-bg-color :foreground mode-line-fg-color))
  89.            (progn
  90.              (set-frame-parameter nil 'fullscreen 'fullboth)
  91.              (menu-bar-mode 0)
  92.              (tool-bar-mode 0)
  93.              (scroll-bar-mode 0)
  94.              (set-face-attribute 'mode-line nil :background background-color :foreground selection-color))))
  95.   (global-set-key (kbd "<f11>") 'toggle-fullscreen)
  96.  
  97.   ) ; X11 specific settings
  98.  
  99. ;;; Text mode specific settings:
  100.  
  101. (unless window-system
  102.   (menu-bar-mode 0)                     ; Hide menu bar. (Still accessible via [F10].)
  103.   (display-time-mode 1)                     ; Show time.
  104.  
  105.   ;;; Xterm-style keyboard escape codes:
  106.  
  107.   (load-file "~/.emacs.d/keymap.el")
  108.  
  109.   ;;; Colors:
  110.  
  111.   (set-face-attribute 'default   nil :background    "blue" :foreground "white")
  112.   (set-face-attribute 'region    nil :background    "cyan"                    )
  113.   (set-face-attribute 'mode-line nil :inverse-video nil    :foreground "cyan" )
  114.  
  115.   ) ; Text mode specific settings
  116.  
  117. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  118.  
  119. ;;; A Word Processor -like mode:
  120.  
  121. (define-derived-mode wp-mode fundamental-mode "WP"
  122.   "A Word Processor -like Mode."
  123.  
  124.   (set-buffer-file-coding-system 'utf-8-unix)           ; Force utf-8 encoding and Unix-style newlines.
  125.   (enriched-mode 1)                     ; Allow Bold and Italics in text.
  126.   (visual-line-mode 1)                      ; Wrap long lines only at whitespace.
  127.   (auto-save-mode 1)                        ; Enable auto save.
  128.  
  129.   ;;; X11 specific settings:
  130.  
  131.   (when (eq window-system 'x)
  132.  
  133.     (setq left-margin-width 32)                 ; Set left margin.
  134.     (setq right-margin-width 32)                ; Set right margin.
  135.     (setq tab-width 8)                      ; Set tab width.
  136.     (toggle-fullscreen)                     ; Start in fullscreen mode.
  137.  
  138.     ;;; Font:
  139.  
  140.     (variable-pitch-mode 1)                 ; Do not use monospaced font
  141.     (setq line-spacing 0.7)                 ; Line spacing (relative to font height)
  142.     (make-face 'wp-font-face)                   ; Create new face and set attributes
  143.     (buffer-face-set 'wp-font-face)             ; Set as default buffer face
  144.     (set-face-attribute 'wp-font-face nil :family "Gentium" :height 144)  ; Font face
  145.  
  146.     ) ; X11 specific settings
  147.  
  148.   ;;; Text mode specific settings:
  149.  
  150.   (unless window-system
  151.     (setq left-margin-width 5)                  ; Set left margin.
  152.     (setq right-margin-width 2)                 ; Set right margin.
  153.     (setq tab-width 5))                     ; Set tab width.
  154.  
  155.   ;;; Mode-line:
  156.  
  157.   (setq minor-mode-alist nil)                   ; Do not list minor modes.
  158.   (size-indication-mode 1)                  ; Show file size.
  159.  
  160.   ;;; Paragraph indentation. Choose the preferred style:
  161.  
  162.   (setq indent-line-function 'insert-tab)           ; Automagically insert tabs.
  163.  
  164.   ;; or, alternatively:
  165.  
  166.   ;(setq indent-line-function 'ignore)              ; Disable automagical indentation.
  167.   ;(local-set-key (kbd "<tab>") 'self-insert-command)       ; Force Tab-key to insert Tab-character.
  168.  
  169.   ;;; Abbreviations:
  170.  
  171.   (abbrev-mode 1)
  172.   (load-file "~/.emacs.d/abbreviations.el")
  173.   (setq save-abbrevs nil)                   ; Do not try to save the abbreviations.
  174. )
  175.  
  176. (add-to-list 'auto-mode-alist '(".wp" . wp-mode))       ; Associate "*.wp" files with wp-mode.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement