Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;; Are we running XEmacs or Emacs?
- (defvar running-xemacs (string-match "XEmacs\\|Lucid" emacs-version))
- ;; disable menu bar when running in terminal
- (when (not (display-graphic-p))
- (menu-bar-mode -1))
- ;;My libraries, ebib, wordcount etc
- (add-to-list 'load-path "~/.emacs-lisp/")
- ;;;;;;;;;;;;;;;
- ;; emacs IDE ;;
- ;;;;;;;;;;;;;;;
- ;; (package-initialize)
- ;; (eide-start)
- (add-to-list 'load-path "/home/terdon/.emacs-lisp/Emacs-PDE-0.2.16/lisp")
- ;;(load "pde-load")
- (load "imenu-tree")
- ;; (setq pde-extra-setting t)
- ;; ;; Load imenu automatically in CPerl mode
- ;; (add-hook 'cperl-mode-hook 'imenu-tree)
- ;; (add-to-list 'load-path "~/.emacs.d/elpa/archives")
- ;; (add-to-list 'load-path "~/.emacs.d/elpa/auto-complete-20160310.2248")
- ;; (add-to-list 'load-path "~/.emacs.d/elpa/eide-2.1.1")
- ;; (add-to-list 'load-path "~/.emacs.d/elpa/gnupg")
- ;; (add-to-list 'load-path "~/.emacs.d/elpa/log4e-20150105.505")
- ;; (add-to-list 'load-path "~/.emacs.d/elpa/plsense-20151104.645")
- ;; (add-to-list 'load-path "~/.emacs.d/elpa/popup-20151222.1339")
- ;; (add-to-list 'load-path "~/.emacs.d/elpa/yaxception-20150105.652")
- ;; (require 'plsense)
- ;; (require 'auto-complete-config)
- ;; (ac-config-default)
- ;; ;; Key binding
- ;; (setq plsense-popup-help-key "C-:")
- ;; (setq plsense-display-help-buffer-key "M-:")
- ;; (setq plsense-jump-to-definition-key "C->")
- ;; ;; Make config suit for you. About the config item, eval the following sexp.
- ;; ;; (customize-group "plsense")
- ;; ;; Do setting recommemded configuration
- ;; (plsense-config-default)
- ;;;;;;;;;;;;;;;;;;;;;
- ;; Disable toolbar ;;
- ;;;;;;;;;;;;;;;;;;;;;
- (tool-bar-mode -1)
- ;;;;;;;;;;;;;;;;;;;;;;
- ;; Disable the bell ;;
- ;;;;;;;;;;;;;;;;;;;;;;
- (setq ring-bell-function 'ignore)
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;; Set the autosave interval to 30 minutes ;;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- (setq auto-save-timeout 1800)
- ;;;;;;;;;;;;;;;;;;;;
- ;; Start a server ;;
- ;;;;;;;;;;;;;;;;;;;;
- ;;(server-start)
- ;; use Shift+arrow_keys to move cursor around split panes
- (windmove-default-keybindings)
- ;; when cursor is on edge, move to the other side, as in a torus space
- (setq windmove-wrap-around t )
- ;;;;;;;;;;;;;;;;;;;;;
- ;; Tabs or spaces? ;;
- ;;;;;;;;;;;;;;;;;;;;;
- (setq-default tab-width 2)
- (setq-default indent-tabs-mode t)
- (defvaralias 'c-basic-offset 'tab-width)
- (defvaralias 'cperl-indent-level 'tab-width)
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;; Enable installing packages from melpa.org ;;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- (require 'package) ;; You might already have this line
- (add-to-list 'package-archives
- '("melpa" . "http://melpa.org/packages/") t)
- (when (< emacs-major-version 24)
- ;; For important compatibility libraries like cl-lib
- (add-to-list 'package-archives '("gnu" . "http://elpa.gnu.org/packages/")))
- (package-initialize) ;; You might already have this line
- ;; ===== Make Text mode the default mode for new buffers =====
- ;;(setq major-mode 'text-mode)
- ;; ===== Make markdown mode the default mode for new buffers =====
- (setq major-mode 'markdown-mode)
- ;;;;;;;;;;;;;;;;;;;;
- ;; org mode stuff ;;
- ;;;;;;;;;;;;;;;;;;;;
- (require 'org-install)
- (add-to-list 'auto-mode-alist '("\\.org$" . org-mode))
- (define-key global-map "\C-cl" 'org-store-link)
- (define-key global-map "\C-ca" 'org-agenda)
- (setq org-log-done t)
- ;; disable blinking cursor
- (blink-cursor-mode 0)
- ;; Interpret ANSI color escape codes
- (add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on)
- ;; Set up the keyboard so the delete key on both the regular keyboard
- ;; and the keypad delete the character under the cursor and to the right
- ;; under X, instead of the default, backspace behavior.
- (global-set-key [delete] 'delete-char)
- (global-set-key [kp-delete] 'delete-char)
- (global-set-key "\C-cc" 'comment-region)
- (global-set-key "\C-cb" 'comment-box)
- (global-set-key "\C-cu" 'uncomment-region)
- (global-set-key "\C-cr" 'query-replace)
- (global-set-key "\M-gg" 'goto-line)
- (global-set-key "\C-ci" 'ebib-insert-bibtex-key)
- ;; (global-set-key "\C-ce" 'ecb-activate)
- ;;; Compare windows
- (global-set-key "\C-cw" 'compare-windows)
- ;;; Rebind `C-x C-b' for `buffer-menu'
- (global-set-key "\C-x\C-b" 'buffer-menu)
- ;; Turn on font-lock mode for Emacs
- (cond ((not running-xemacs)
- (global-font-lock-mode t)
- ))
- ;; use all spaces, no tabs for indentation
- ;;(setq-default indent-tabs-mode nil)
- ;; delete with backspace and delete
- (delete-selection-mode t)
- (add-hook 'LaTeX-mode-hook 'flyspell-mode)
- ;; make flyspell mode ignore latex commands
- (setq ispell-extra-args '("--dont-tex-check-comments"))
- ;;(set-default-font "-apple-Monaco-normal-normal-normal-*-14-*-*-*-*-0-iso10646-1")
- (set-default-font "Monaco")
- ;; set font size
- (set-face-attribute 'default nil :height 110)
- ;;(set-default-font "monaco")
- ;;-*-Monaco-normal-r-*-*-16-*-*-*-*-*-*-*")
- ;;;; -*-Monaco-medium-r-*-*-10-*-*-*-*-*-*-*
- ;; Visual feedback on selections
- (setq-default transient-mark-mode t)
- ;; Always end a file with a newline
- (setq require-final-newline t)
- ;; Stop at the end of the file, not just add lines
- (setq next-line-add-newlines nil)
- ;; highlight paired parentheses
- (show-paren-mode t )
- ;; Pretty parentheses
- (when (require 'rainbow-delimiters nil 'noerror)
- (add-hook 'cperl-mode-hook 'rainbow-delimiters-mode))
- ;;;;;;;;;;;;;;;;;;;;;
- ;; auto-install.el ;;
- ;;;;;;;;;;;;;;;;;;;;;
- ;; (require 'auto-install)
- ;; (auto-install-update-emacswiki-package-name t)
- ;;;;;;;;;;;;;;;;;;;;;
- ;; perl completion ;;
- ;;;;;;;;;;;;;;;;;;;;;
- (add-hook 'cperl-mode-hook
- (lambda()
- (require 'perl-completion)
- (perl-completion-mode t)))
- ;;;;;;;;;;;;;;;;;;;;
- ;; ----- ECB ---- ;;
- ;;;;;;;;;;;;;;;;;;;;
- ;; (add-to-list 'load-path
- ;; "~/.emacs-lisp/ecb/");;"/usr/share/emacs23/site-lisp/ecb/")
- ;; (require 'ecb)
- ;;;; activate ecb for the following modes
- ;; (dolist (hook '(
- ;; c-mode-hook
- ;; cperl-mode-hook
- ;; perl-mode-hook
- ;; php-mode-hook
- ;; js-mode-hook
- ;; python-mode
- ;; sh-mode-hook
- ;; ))
- ;; (add-hook hook 'ecb-activate))
- ;;; Modify the variable ecb-layout-name to use change the layout
- ;;; then C-c . l to refresh the ecb screen
- ;;; or just use the function ecb-change-layout
- ;;(setq ecb-layout-name "terdon1")
- ;;(setq ecb-layout-name "terdon2")
- ;(setq initial-buffer-choice user-init-file)
- ;;; use the icons in the tree displays (t)
- ;;(setq ecb-tree-use-image-icons t)
- ;; Enable wheelmouse support by default
- (cond (window-system
- (mwheel-install)
- ))
- (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.
- '(case-fold-search t)
- '(current-language-environment "English")
- '(custom-enabled-themes (quote (tango-dark)))
- '(custom-safe-themes
- (quote
- ("38908037082b9fc2e6762961026299d026963e57c726c3bc0b9e66cd0def0926" default)))
- '(default-input-method "latin-9-prefix")
- '(ebib-preload-bib-files (quote ("~/doc/Papers/moonlighting.bib")))
- '(global-font-lock-mode t nil (font-lock))
- '(inhibit-startup-screen t)
- '(safe-local-variable-values (quote ((Local . "american"))))
- '(save-place t nil (saveplace))
- '(show-paren-mode t nil (paren))
- '(tex-dvi-view-command
- (quote
- (cond
- ((eq window-system
- (quote x))
- "evince")
- ((eq window-system
- (quote w32))
- "yap")
- (t "dvi2tty * | cat -s"))))
- '(transient-mark-mode t))
- (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.
- '(cperl-array-face ((((class color) (background light)) (:foreground "OrangeRed"))))
- '(cperl-hash-face ((((class color) (background light)) (:foreground "coral4"))))
- '(cperl-nonoverridable-face ((t (:foreground "RoyalBlue"))))
- '(font-lock-comment-face ((t (:foreground "SlateGray"))))
- '(markdown-header-face-1 ((t (:inherit markdown-header-face :height 1.1))))
- '(markdown-header-face-2 ((t (:inherit markdown-header-face :height 1.05))))
- '(markdown-header-face-3 ((t (:inherit markdown-header-face :height 1.03))))
- '(markdown-header-face-4 ((t (:inherit markdown-header-face :height 1.01)))))
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;; enable highlighting regions from the keyboard ;;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- (setq transient-mark-mode t)
- ;; Load Ebib mode
- (autoload 'ebib "ebib" "Ebib, a BibTeX database manager." t)
- ;; Load wc mode
- (autoload 'wc "wc" "Word Count" t)
- ;; enable wordcount for LaTex
- ;; http://superuser.com/questions/125027/word-count-for-latex-within-emacs
- (defun latex-word-count ()
- (interactive)
- (shell-command (concat "~/scripts/texcount.pl "
- ; "uncomment then options go here "
- (buffer-file-name))))
- ;; save history across sessions
- (require 'recentf)
- (recentf-mode 1)
- (setq recentf-max-menu-items 50)
- ;; ralee mode is good for RNA alignment editing
- ;; (add-to-list 'load-path "~/.ralee/")
- ;; (autoload 'ralee-mode "ralee-mode" "Yay! RNA things" t)
- ;; (setq auto-mode-alist (cons '("\\.stk$" . ralee-mode) auto-mode-alist))
- ;; Show current line and column number
- (setq-default column-number-mode t)
- (line-number-mode t)
- ;; Set encoding
- (prefer-coding-system 'utf-8)
- (setq coding-system-for-read 'utf-8)
- (setq coding-system-for-write 'utf-8)
- ;; tramp for remote file editing
- (setq tramp-default-method "sshx")
- (setq tramp-verbose 10)
- ;;/lacoloc@badabing:/home/lacoloc/foo1
- ;;; Buffer tricks for C-x C-b
- (require 'ibuffer)
- (setq ibuffer-saved-filter-groups
- (quote (("default"
- ("Coding" ;; prog stuff not already in MyProjectX
- (or
- (mode . c-mode)
- (mode . perl-mode)
- (mode . cperl-mode)
- (mode . python-mode)
- (mode . emacs-lisp-mode)
- (mode . php-mode)
- (mode . js-mode)
- (mode . shell-script\[sh\]-mode)
- (mode . shell-script\[bash\]-mode)
- (mode . shell-script-mode)
- (mode . shell-script-mode)
- (mode . shell-script-mode)
- (mode . shell-script-mode)
- (name . "\\.sh$")
- )
- )
- ("HTML/CSS"
- (or
- (mode . myhtml-mode)
- (mode . html-mode)
- (mode . htm-mode)
- (mode . css-mode)
- )
- )
- ("PlainText" (mode . text-mode))
- ))))
- (add-hook 'ibuffer-mode-hook
- (lambda ()
- (ibuffer-switch-to-saved-filter-groups "default")))
- (global-set-key (kbd "C-x C-b") 'ibuffer)
- ;;;;;; HTML stuff ;;;;;;;;;;;
- ;;;;;;; Color colors in css and html files
- (autoload 'myhtml-mode "myhtml-mode" "My HTML mode." t)
- (autoload 'rainbow-mode "rainbow-mode" "Color stuff" t)
- ;;; set myHTML as default mode
- (setq auto-mode-alist (cons '("\\.html$" . myhtml-mode) auto-mode-alist))
- ;;; web-mode single mode for web docs
- (require 'web-mode)
- (add-to-list 'auto-mode-alist '("\\.phtml\\'" . web-mode))
- (add-to-list 'auto-mode-alist '("\\.php\\'" . web-mode))
- (add-to-list 'auto-mode-alist '("\\.css\\'" . web-mode))
- (add-to-list 'auto-mode-alist '("\\.html\\'" . web-mode))
- (add-to-list 'auto-mode-alist '("\\.htm\\'" . web-mode))
- (add-hook 'css-mode-hook 'rainbow-mode)
- ;;;;;;;;;; HTML keybindings ;;;;;;;;
- ;;; Ctrl+c Ctrl+d :Delete matching tags. WARNING: if your HTML tags
- ;;; are not always matched, it might delete the wrong starting/ending tag
- (add-hook 'myhtml-mode-hook
- (lambda ()
- ;;; sgml-delete-tag function
- (local-set-key (kbd "C-c b") 'bold-word)
- (local-set-key (kbd "C-c p") 'insert-p)
- (local-set-key (kbd "M-4") 'tag-image)
- (local-set-key (kbd "M-5") 'wrap-url)
- (local-set-key (kbd "C-c C-d") 'sgml-delete-tag)
- )
- )
- ;;; Idle highlight stuff
- ;; (defun my-coding-hook () (make-local-variable 'column-number-mode) (column-number-mode t) (idle-highlight t))
- ;; (add-hook 'emacs-lisp-mode-hook 'my-coding-hook) (add-hook 'ruby-mode-hook 'my-coding-hook) (add-hook 'js2-mode-hook 'my-coding-hook) (add-hook 'perl-mode-hook 'my-coding-hook) (add-hook 'python-mode-hook 'my-coding-hook) (add-hook 'php-mode-hook 'my-coding-hook) (add-hook 'js-mode-hook 'my-coding-hook)
- ;;; This was installed by package-install.el.
- ;;; This provides support for the package system and
- ;;; interfacing with ELPA, the package archive.
- ;;; Move this code earlier if you want to reference
- ;;; packages in your .emacs.
- ;; (when
- ;; (load
- ;; (expand-file-name "~/.emacs.d/elpa/package.el"))
- ;; (package-initialize))
- ;;
- (define-key isearch-mode-map (kbd "C-o")
- (lambda ()
- (interactive)
- (let ((case-fold-search isearch-case-fold-search))
- (occur (if isearch-regexp isearch-string
- (regexp-quote isearch-string))))))
- ;;; yasnippet for tab autocomplete
- ;;; https://github.com/capitaomorte/yasnippet
- (add-to-list 'load-path
- "~/.emacs.d/plugins/yasnippet")
- (require 'yasnippet)
- (yas/global-mode 1)
- ;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;; Customize cperl-mode ;;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;; make cperl-mode always highlight scalar variables
- (setq cperl-highlight-variables-indiscriminately t)
- ;; Disable whitespace underline
- (setq cperl-invalid-face (quote off))
- ;; Set as default for perl files
- (require 'cperl-mode)
- ;; Perl file extension associations
- (add-to-list 'auto-mode-alist '("\\.pl$" . cperl-mode))
- (add-to-list 'auto-mode-alist '("\\.ph$" . cperl-mode))
- (add-to-list 'auto-mode-alist '("\\.cgi$" . cperl-mode))
- (add-to-list 'auto-mode-alist '("\\.pm$" . cperl-mode))
- (add-to-list 'interpreter-mode-alist '("perl" . cperl-mode))
- (add-to-list 'auto-mode-alist '("\\.pl$" . cperl-mode))
- (add-to-list 'auto-mode-alist '("\\.cgi$" . cperl-mode))
- (add-to-list 'auto-mode-alist '("\\.pm$" . cperl-mode))
- (add-to-list 'interpreter-mode-alist '("perl" . cperl-mode))
- (add-to-list 'auto-mode-alist '("\\.pm$" . cperl-mode))
- ;; BSD/Allman indentation style using cperl-mode
- (cperl-set-style "BSD")
- (setq cperl-electric-keywords t) ;; expands for keywords such as
- ;; foreach, while, etc...
- ;; Load README files with markdown-mode
- (add-to-list 'auto-mode-alist '(".*README.*" . markdown-mode))
- ; Outline-minor-mode key map
- (define-prefix-command 'cm-map nil "Outline-")
- ; HIDE
- (define-key cm-map "q" 'hide-sublevels) ; Hide everything but the top-level headings
- (define-key cm-map "t" 'hide-body) ; Hide everything but headings (all body lines)
- (define-key cm-map "o" 'hide-other) ; Hide other branches
- (define-key cm-map "c" 'hide-entry) ; Hide this entry's body
- (define-key cm-map "l" 'hide-leaves) ; Hide body lines in this entry and sub-entries
- (define-key cm-map "d" 'hide-subtree) ; Hide everything in this entry and sub-entries
- ; SHOW
- (define-key cm-map "a" 'show-all) ; Show (expand) everything
- (define-key cm-map "e" 'show-entry) ; Show this heading's body
- (define-key cm-map "i" 'show-children) ; Show this heading's immediate child sub-headings
- (define-key cm-map "k" 'show-branches) ; Show all sub-headings under this heading
- (define-key cm-map "s" 'show-subtree) ; Show (expand) everything in this heading & below
- ; MOVE
- (define-key cm-map "u" 'outline-up-heading) ; Up
- (define-key cm-map "n" 'outline-next-visible-heading) ; Next
- (define-key cm-map "p" 'outline-previous-visible-heading) ; Previous
- (define-key cm-map "f" 'outline-forward-same-level) ; Forward - same level
- (define-key cm-map "b" 'outline-backward-same-level) ; Backward - same level
- (global-set-key "\M-o" cm-map)
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;; Make TAB expand words. Source: ;;
- ;; http://emacsblog.org/2007/03/12/tab-completion-everywhere/ ;;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- (defun my-tab-fix ()
- (local-set-key [tab] 'indent-or-expand))
- (add-hook 'c-mode-hook 'my-tab-fix)
- (add-hook 'cperl-mode-hook 'my-tab-fix)
- (add-hook 'php-mode-hook 'my-tab-fix)
- (add-hook 'js-mode-hook 'my-tab-fix)
- (add-hook 'python-mode 'my-tab-fix)
- (add-hook 'sh-mode-hook 'my-tab-fix)
- (add-hook 'emacs-lisp-mode-hook 'my-tab-fix)
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;; Define the indent-or-expand function we ;;
- ;; just mapped to TAB ;;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- (defun indent-or-expand (arg)
- "Either indent according to mode, or expand the word preceding
- point."
- (interactive "*P")
- (if (and
- (or (bobp) (= ?w (char-syntax (char-before))))
- (or (eobp) (not (= ?w (char-syntax (char-after))))))
- (dabbrev-expand arg)
- (indent-according-to-mode)))
- ;;; Stop emacs from showing buffer menu when >=3 files opened
- (setq inhibit-startup-buffer-menu t)
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;; Bury unwanted buffers ;;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; necessary support function for buffer burial
- (defun crs-delete-these (delete-these from-this-list)
- "Delete DELETE-THESE FROM-THIS-LIST."
- (cond
- ((car delete-these)
- (if (member (car delete-these) from-this-list)
- (crs-delete-these (cdr delete-these) (delete (car delete-these)
- from-this-list))
- (crs-delete-these (cdr delete-these) from-this-list)))
- (t from-this-list)))
- ; this is the list of buffers I never want to see
- (defvar crs-hated-buffers
- '("KILL" "*Compile-Log*" "*Messages*" "*scratch*" "*auto-install"))
- ; might as well use this for both
- (setq iswitchb-buffer-ignore (append '("^ " "*Buffer") crs-hated-buffers))
- (defun crs-hated-buffers ()
- "List of buffers I never want to see, converted from names to buffers."
- (delete nil
- (append
- (mapcar 'get-buffer crs-hated-buffers)
- (mapcar (lambda (this-buffer)
- (if (string-match "^ " (buffer-name this-buffer))
- this-buffer))
- (buffer-list)))))
- ; I'm sick of switching buffers only to find KILL right in front of me
- (defun crs-bury-buffer (&optional n)
- (interactive)
- (unless n
- (setq n 1))
- (let ((my-buffer-list (crs-delete-these (crs-hated-buffers)
- (buffer-list (selected-frame)))))
- (switch-to-buffer
- (if (< n 0)
- (nth (+ (length my-buffer-list) n)
- my-buffer-list)
- (bury-buffer)
- (nth n my-buffer-list)))))
- (global-set-key [(control tab)] 'crs-bury-buffer)
- (global-set-key [(control meta tab)] (lambda ()
- (interactive)
- (crs-bury-buffer -1)))
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;; ETAGS ;;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- (defun create-tags (dir-name)
- "Create tags file."
- (interactive "DDirectory: ")
- (eshell-command
- (format "find %s -type f -name \"*.[ch]\" | etags -L -" dir-name)))
- ;;; Jonas.Jarnestrom<at>ki.ericsson.se A smarter
- ;;; find-tag that automagically reruns etags when it cant find a
- ;;; requested item and then makes a new try to locate it.
- ;;; Fri Mar 15 09:52:14 2002
- (defadvice find-tag (around refresh-etags activate)
- "Rerun etags and reload tags if tag not found and redo find-tag.
- If buffer is modified, ask about save before running etags."
- (let ((extension (file-name-extension (buffer-file-name))))
- (condition-case err
- ad-do-it
- (error (and (buffer-modified-p)
- (not (ding))
- (y-or-n-p "Buffer is modified, save it? ")
- (save-buffer))
- (er-refresh-etags extension)
- ad-do-it))))
- (defun er-refresh-etags (&optional extension)
- "Run etags on all peer files in current dir and reload them silently."
- (interactive)
- (shell-command (format "etags *.%s" (or extension "el")))
- (let ((tags-revert-without-query t)) ; don't query, revert silently
- (visit-tags-table default-directory nil)))
- (global-set-key "\M-s" 'tags-search)
- ;;; Delete buffer
- ;;(kill-buffer "*Completions*")
- ;;;;;;;; Color theme ;;;;;;;;;;;;;;
- (defun color-theme-djcb-dark ()
- "dark color theme created by djcb, Jan. 2009."
- (interactive)
- (color-theme-install
- '(color-theme-djcb-dark
- ((foreground-color . "#a9eadf")
- (background-color . "black")
- (background-mode . dark))
- (bold ((t (:bold t))))
- (bold-italic ((t (:italic t :bold t))))
- (default ((t (nil))))
- (font-lock-builtin-face ((t (:italic t :foreground "#a96da0"))))
- (font-lock-comment-face ((t (:italic t :foreground "#bbbbbb"))))
- (font-lock-comment-delimiter-face ((t (:foreground "#666666"))))
- (font-lock-constant-face ((t (:bold t :foreground "#197b6e"))))
- (font-lock-doc-string-face ((t (:foreground "#3041c4"))))
- (font-lock-doc-face ((t (:foreground "gray"))))
- (font-lock-reference-face ((t (:foreground "white"))))
- (font-lock-function-name-face ((t (:foreground "#356da0"))))
- (font-lock-keyword-face ((t (:bold t :foreground "#bcf0f1"))))
- (font-lock-preprocessor-face ((t (:foreground "#e3ea94"))))
- (font-lock-string-face ((t (:foreground "#ffffff"))))
- (font-lock-type-face ((t (:bold t :foreground "#364498"))))
- (font-lock-variable-name-face ((t (:foreground "#7685de"))))
- (font-lock-warning-face ((t (:bold t :italic nil :underline nil
- :foreground "yellow"))))
- (hl-line ((t (:background "#112233"))))
- (mode-line ((t (:foreground "#ffffff" :background "#333333"))))
- (region ((t (:foreground nil :background "#555555"))))
- (show-paren-match-face ((t (:bold t :foreground "#ffffff"
- :background "#050505")))))))
- (add-to-list 'process-coding-system-alist '("zsh" . utf-8))
- (put 'upcase-region 'disabled nil)
- ;; Informative comments,
- ;; comments that I want to keep or whatever
- (add-hook 'tex-mode-hook
- (lambda ()
- (font-lock-add-keywords nil
- ;;'(("\\<\\(FIXME\\|TODO\\|HACK\\|fixme\\|todo\\|hack\\)" 1
- '(("\\(%#.*\\)" 1
- font-lock-warning-face t)))))
- (add-hook 'cperl-mode-hook
- (lambda ()
- (font-lock-add-keywords nil
- '(("\\(#%.*\\)" 1
- font-lock-warning-face t)))))
- ;;;;;;;;;;;;;;;;;;;;
- ;; Enable tabbar ;;
- ;;;;;;;;;;;;;;;;;;;;
- ;(tabbar-mode t)
- ;;; Markdown mode
- (autoload 'markdown-mode "markdown-mode.el" "Major mode for editing Markdown files" t)
- (setq auto-mode-alist (cons '("\\.text$" . markdown-mode) auto-mode-alist))
- (setq auto-mode-alist (cons '("\\.md$" . markdown-mode) auto-mode-alist))
- (setq auto-mode-alist (cons '("\\.mdown$" . markdown-mode) auto-mode-alist))
- (setq auto-mode-alist (cons '("\\.mdt$" . markdown-mode) auto-mode-alist))
- (setq auto-mode-alist (cons '("\\.markdown$" . markdown-mode) auto-mode-alist))
- ;;;;;;;;;;;;;;;;;;
- ;; Color themes ;;
- ;;;;;;;;;;;;;;;;;;
- (add-to-list 'load-path "~/.emacs-lisp/emacs-color-theme-solarized")
- (load-theme 'tango-dark)
- ;;;;;;;;;;;;;;;;;
- ;; LaTeX stuff ;;
- ;;;;;;;;;;;;;;;;;
- (setq TeX-PDF-mode t)
- (setq TeX-auto-save t)
- (setq TeX-parse-self t)
- (setq-default TeX-master nil)
- (add-hook 'LaTeX-mode-hook 'visual-line-mode)
- (add-hook 'LaTeX-mode-hook 'flyspell-mode)
- (add-hook 'LaTeX-mode-hook 'LaTeX-math-mode)
- (add-hook 'LaTeX-mode-hook 'turn-on-reftex)
- (setq reftex-plug-into-AUCTeX t)
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;; Chrome edit with emacs extension ;;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- (add-to-list 'load-path "~/.emacs.d/plugins")
- (require 'edit-server)
- (edit-server-start)
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;; Enable markdown mode for editing SE posts ;;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;; Integrate Emacs with Stack Exchange http://stackoverflow.com/a/10386560/789593
- (add-to-list 'auto-mode-alist '("stack\\(exchange\\|overflow\\)\\.com\\.[a-z0-9]+\\.txt" . markdown-mode))
- (add-to-list 'auto-mode-alist '("superuser\\.com\\.[a-z0-9]+\\.txt" . markdown-mode))
- ;; Insert text around a region. In this case, it's
- ;; the LaTeX code environment from the listings package
- (defun wrap-code (start end)
- "Insert a \begin{code} and \end{code} around a region."
- (interactive "r")
- (save-excursion
- (goto-char end) (insert "\\end{code}")
- (goto-char start)(insert "\\begin{code}") (newline-and-indent)
- ))
- ;; Assign its shortcut
- (global-set-key (kbd "C-c p") 'wrap-code)
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;; SE Markdown: http://emacs.stackexchange.com/questions/723/how-can-i-use-the-se-flavor-of-markdown-in-emacs ;;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;; This variable controls how you want lists to look. It adds some space ;;
- ;; to indent the list, and uses a pretty bullet-point. ;;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- (defvar endless/bullet-appearance
- (propertize (if (char-displayable-p ?•) " •" " *")
- 'face 'markdown-list-face)
- "String to be displayed as the bullet of markdown list items.")
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;; This is the command that actually adds the rules. There is one for lists and one for links. ;;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- (font-lock-add-keywords
- 'markdown-mode
- '(("^ *\\(\\*\\|\\+\\|-\\|\\) "
- 1 `(face nil display ,endless/bullet-appearance) prepend)
- ("\\[[^]]*\\]\\(([^)]*)\\|\\[[^]]*\\]\\)"
- 1 '(face nil display "") prepend))
- 'append)
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;; Because we’re using the display property to hide part of the link, ;;
- ;; we need to tell font-lock that it should erase that property whenever ;;
- ;; you delete part of the link (that way we can still edit it). ;;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- (add-hook 'markdown-mode-hook #'endless/markdown-font-lock)
- (defun endless/markdown-font-lock ()
- "Configure aggressive font-locking of `markdown-mode'."
- (add-to-list (make-local-variable 'font-lock-extra-managed-props) 'display))
- ;; Faces
- ;; Insert links and make them editable
- (add-hook 'markdown-mode-hook #'endless/markdown-font-lock)
- (defun endless/markdown-font-lock ()
- "Configure aggressive font-locking of `markdown-mode'."
- (define-key markdown-mode-map "\C-c\C-l" #'endless/markdown-insert-link)
- (add-to-list (make-local-variable 'font-lock-extra-managed-props) 'display))
- (defun endless/markdown-insert-link ()
- "Insert or edit link at point."
- (interactive)
- (if (or (looking-at endless/markdown-link-regexp)
- (and (ignore-errors (backward-up-list) t)
- (or (looking-at endless/markdown-link-regexp)
- (and (forward-sexp -1)
- (looking-at endless/markdown-link-regexp)))))
- (let ((data (endless/ask-for-link
- (match-string-no-properties 1)
- (or (match-string-no-properties 2)
- (match-string-no-properties 3)))))
- (if (match-string-no-properties 2)
- (replace-match (cdr data) :fixedcase :literal nil 2)
- (replace-match (cdr data) :fixedcase :literal nil 3))
- (replace-match (car data) :fixedcase :literal nil 1))
- (let ((data (endless/ask-for-link)))
- (insert "[" (car data) "](" (cdr data) ")"))))
- (defun endless/ask-for-link (&optional name link)
- (cons (read-string "Text of the link: " name)
- (read-string "URL of the link: " link)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement