.emacs 2

I will post my configuration files for Emacs (24.2.1) here.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ …

~/.emacs.d/init.el

Very basic. Mainly it loads custom.el (for customize stuff), init_emacs_basic.el for basic adjustments and init_emacs_js.el for JavaScript specific stuff. But you'll also find some small tests here (mumamo, tabbar, keys, erc). If the tests are successful the lines will go into the basic or js init-file.

;; Mumamo is making emacs 23.3 freak out:
(setq warning-minimum-level :error) 

;; Font
(set-face-attribute 'default nil :font "Bitstream Vera Sans Mono")

;; Load external files
(setq custom-file "~/.emacs.d/custom.el")
(load custom-file)

(load "~/.emacs.d/init_emacs_basic.el")

(load "~/.emacs.d/init_emacs_js.el")


;; ,----
;; | Tabbar
;; `----
;; (load "~/.emacs.d/tabbar.el")
;; (tabbar-mode 1)

(global-set-key (quote [C-f10]) (quote indent-region))

;; ,----
;; | Org-Mode Other Window
;; `----
(add-hook 'org-mode-hook
          (lambda () 
            (local-unset-key [C-tab])))

;; ,----
;; | Highlight current line
;; `----
; (global-hl-line-mode 1)
;; To customize the background color
;; (set-face-background 'hl-line "#330")


;; ,----
;; | ERC
;; `----
(setq erc-hide-list '("JOIN" "PART" "QUIT"))

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

~/.emacs.d/custom.el

Here you'll find the lines changed by the Emacs Customization (M-x customize-…) Customization is nice but doesn't fit very well into the configuration files structure, so I don't like that file very much.

(custom-set-variables
 ;; custom-set-variables was added by Custom.
 ;; 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.
 '(backup-directory-alist (quote (("." . "~/.backups"))))
 '(blink-cursor-mode nil nil (frame))
 '(calendar-week-start-day 1)
 '(case-fold-search t)
 '(column-number-mode t)
 '(current-language-environment "German")
 '(default-input-method "german-postfix")
 '(fill-column 76)
 '(global-font-lock-mode t nil (font-lock))
 '(indent-tabs-mode nil)
 '(inhibit-startup-screen t)
 '(load-home-init-file t t)
 '(make-backup-files nil)
 '(mm-text-html-renderer (quote html2text))
 '(mumamo-chunk-coloring 2)
 '(require-final-newline t)
 '(show-paren-mode 1)
 '(show-paren-style (quote mixed))
 '(tab-width 4)
 '(tool-bar-mode nil))
(custom-set-faces
 ;; custom-set-faces was added by Custom.
 ;; 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.
 )

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.emacs.d/emacs_init_basic.el

The basic customization of my Emacs. UTF-8 support, some basic functions, Diary, Boxquote, Themes, Aspell, …

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; BASIC CONFIGUATION OF EMACS
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


;; ,----
;; | UTF-8
;; `----
;; http://blog.jonnay.net/archives/820-Emacs-and-UTF-8-Encoding.html
;; set up unicode
(prefer-coding-system 'utf-8)
(set-default-coding-systems 'utf-8)
(set-terminal-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8)
;; This from a japanese individual.  I hope it works.
(setq default-buffer-file-coding-system 'utf-8)
;; From Emacs wiki
(setq x-select-request-type '(UTF8_STRING COMPOUND_TEXT TEXT STRING))
;; MS Windows clipboard is UTF-16LE
(set-clipboard-coding-system 'utf-16le-dos)


;; ,----
;; | Query Replace in open Buffers
;; `----
(defun query-replace-in-open-buffers (arg1 arg2)
  "query-replace in open files"
  (interactive "sQuery Replace in open Buffers: nsquery with: ")
  (mapcar
   (lambda (x)
     (find-file x)
     (save-excursion
       (beginning-of-buffer)
       (query-replace arg1 arg2)))
   (delq
    nil
    (mapcar
     (lambda (x)
       (buffer-file-name x))
     (buffer-list)))))


;; ,----
;; | Duplicate line
;; `----
(defun duplicate-line()
 "Duplicate line."
 (interactive)
 (let (
       (beg (line-beginning-position))
       (end (line-end-position)))
   (copy-region-as-kill beg end)
   (beginning-of-line)
   (forward-line 1)
   (yank)
   (newline)
   (forward-line -1)))

;; ,----
;; | Beenden mit Nachfrage
;; `----
(setq kill-emacs-query-functions
      (cons (lambda () (y-or-n-p "Quit Emacs? "))
            kill-emacs-query-functions))

;; ,----
;; | Quote Other Window (Control-Tab)
;; `----

(global-set-key (quote [C-tab]) (quote other-window))
;; --> default: C-x o

;; ,----
;; | Titlebar mit Dateiname
;; `----

(setq frame-title-format (concat "%f (%b) - %F " emacs-version))

;; ,----
;; |  Menu
;; `----

(require 'easymenu) 
(easy-menu-add-item nil 
                    (list (if (>= emacs-major-version 22) "Tools" "tools")) 
                    '("My Commands" 
                      ["Kill rectangle" kill-rectangle t] 
                      ["Sort lines" sort-lines t]))

 
;; ,----
;; | Diary
;; `----
;;Fancy display

;; Here is some code to make your calendar and diary display fancier:
(setq view-diary-entries-initially t
      mark-diary-entries-in-calendar t
      number-of-diary-entries 7)
(add-hook 'diary-display-hook 'fancy-diary-display)
(add-hook 'today-visible-calendar-hook 'calendar-mark-today)

;; Here is some code to get rid of the ugly equal signs under the date:
(add-hook 'fancy-diary-display-mode-hook
          '(lambda ()
             (alt-clean-equal-signs)))

(defun alt-clean-equal-signs ()
  "This function makes lines of = signs invisible."
  (goto-char (point-min))
  (let ((state buffer-read-only))
    (when state (setq buffer-read-only nil))
    (while (not (eobp))
      (search-forward-regexp "^=+$" nil 'move)
      (add-text-properties (match-beginning 0) 
                           (match-end 0) 
                           '(invisible t)))
    (when state (setq buffer-read-only t))))

;; Diary Localization
;; German

;; Here's the code to make it all German. It changes the date format for
;; your diary entries to European style, makes Monday the first day of the
;; week, and changes weekday and month names.
                                        ;(european-calendar)
(setq calendar-week-start-day 1
      calendar-day-name-array
      ["Sonntag" "Montag" "Dienstag" "Mittwoch" 
       "Donnerstag" "Freitag" "Samstag"]
      calendar-month-name-array
      ["Januar" "Februar" "März" "April" "Mai" 
       "Juni" "Juli" "August" "September" 
       "Oktober" "November" "Dezember"])

;; ,----
;; | Boxquote
;; `----
(add-to-list 'load-path "~/.emacs.d/")
(require 'boxquote)

;; ,----
;; | Color Themes
;; `----
(add-to-list 'load-path "~/.emacs.d/color-theme-6.6.0/")
(require 'color-theme)
(require 'birds-of-paradise-plus-theme)


;; ,----
;; | ASPELL
;; `----
;; (setq-default ispell-program-name "aspell")
(setq ispell-program-name "aspell") 

;; alist leeren und für aspell /de_DE.UTF-8 richtig eingestellen: 
(setq ispell-local-dictionary-alist nil) 
(add-to-list 'ispell-local-dictionary-alist 
	     '("deutsch8" 
 	       "[[:alpha:]]" "[^[:alpha:]]"
	       "[']" t
	       ("-C" "-d" "deutsch")
 	        "~latin1" iso-8859-1)
 	     )

(setq ispell-dictionary "deutsch8")
(setq ispell-local-dictionary "deutsch8")
(setq ispell-default-dictionary "deutsch8")
(setq flyspell-default-dictionary "deutsch8") 

(defun turn-on-flyspell-mode () 
   (flyspell-mode 1)
) 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.emacs.d/emacs_init_js.el

Stuff for JavaScript editing. I use nxhtml, the out-of-the-box js-mode, nav, project mode, flymake, auto-complete and yasnippet.

A note on flymake and jshint. I use flymake to lint my JS-files. I use jshint for that. You can install that with node.js and npm. The usage is very easy. Call "jshint" (under Windows it's a command) with your file. You don't need a reporter file and each line represents an error. With my regular expression I can see the errors in flymake and in the minibuffer (with flymake-cursor).

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; SPECIAL EMACS CUSTOMIZATIONS FOR JAVASCRIPT EDITING
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;



;; ,----
;; | Open HTML with Firefox as default
;; `----
(setq browse-url-firefox-program "C:/Program Files (x86)/Mozilla Firefox/firefox.exe")
(setq browse-url-generic-program "C:/Program Files (x86)/Mozilla Firefox/firefox.exe"
      browse-url-browser-function 'browse-url-generic) 

;; ,----
;; | BROWSE URL WITH URL NOT FILE PATH IN BROWSER
;; `----
;; http://www.emacswiki.org/emacs/BrowseUrl
;; 
;; (add-to-list 'browse-url-filename-alist
;;  '("/var/www/cgi/files/" . "http://my.website.com/cgi?"))
(setq browse-url-filename-alist
      '(("C:/inetpub/wwwroot/" . "http://localhost/")))
(global-set-key (quote [C-f11]) 'browse-url-of-file)


;; ,----
;; | NAV
;; `----
(add-to-list 'load-path "~/.emacs.d/emacs-nav-49/")
(require 'nav)
(nav-disable-overeager-window-splitting)
;; Optional: set up a quick key to toggle nav
(global-set-key [f11] 'nav-toggle)




;; ,----
;; | PROJECT MODE
;; `----
(require 'project-mode)
(project-load-all) ; Loads all saved projects. Not required.


;;,----
;;| nXhtml MODE
;;`----
(load "~/.emacs.d/nxhtml/autostart.el")
(tabkey2-mode 1)
;; Completion normally M-Tab
;; M-x tabkey2-mode
;; Wrong colors in Mumamo
;;  M-x mumamo-no-chunk-coloring
;; ,----
;; | FLYMAKE
;; `----
(when (load "flymake" t)
  (defun flymake-jslint-init ()
    (let* ((temp-file (flymake-init-create-temp-buffer-copy
                       'flymake-create-temp-inplace))
           (local-file (file-relative-name
                        temp-file
                        (file-name-directory buffer-file-name))))
      (list "jshint" (list local-file))))

  (setq flymake-err-line-patterns
        ;; tester.js: line 23, col 15, Expected ':' and instead saw '='.
        ;; "^\(.*\): line \([[:digit:]]*\), col [[:digit:]]*, \(.*\)$"
	(cons '("^\(.*\): line \([[:digit:]]*\), col [[:digit:]]*, \(.*\)$"
            1 2 nil 3)
	      flymake-err-line-patterns))

  (add-to-list 'flymake-allowed-file-name-masks
               '("\.js\'" flymake-jslint-init))

  (require 'flymake-cursor)
  )

;; Turns on flymake for all files which have a flymake mode
(add-hook 'find-file-hook 'flymake-find-file-hook)


(add-hook 'js-mode-hook
 	  (lambda ()
       (flymake-mode 1)
       (define-key js-mode-map "C-cC-n" 'flymake-goto-next-error)))


;; ,----
;; | AUTO-COMPLETE
;; `----
(add-to-list 'load-path "~/.emacs.d/")
(require 'auto-complete-config)
(add-to-list 'ac-dictionary-directories "~/.emacs.d/ac-dict")
(ac-config-default)


;; ,----
;; | YASNIPPET
;; `----
;; installed by M-x list-packkages
(add-to-list 'load-path "~/.emacs.d/elpa/yasnippet-0.8.0")
(require 'yasnippet)
(yas-global-mode 1)
;; Let's have snippets in the auto-complete dropdown
(add-to-list 'ac-sources 'ac-source-yasnippet)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Advertisements