Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (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.
- '(php-completion-file "~/.emacs.d/php-completion-file")
- '(php-manual-path "/your/path/to/manuals/php/php-chunked-xhtml")
- '(scalable-fonts-allowed t)
- '(scroll-bar-mode nil)
- '(show-paren-mode t)
- '(size-indication-mode t)
- '(tool-bar-mode nil)
- '(tooltip-mode nil)
- '(tooltip-use-echo-area t)
- '(x-select-enable-clipboard t))
- ;;;; (defadvice desktop-restore-file-buffer
- ;;;; (around my-desktop-restore-file-buffer-advice)
- ;;;; "Be non-interactive while starting a daemon."
- ;;;; (if (and (daemonp)
- ;;;; (not server-process))
- ;;;; (let ((noninteractive t))
- ;;;; ad-do-it)
- ;;;; ad-do-it))
- ;;;; (ad-activate 'desktop-restore-file-buffer)
- ;;; desktop-override-stale-locks.el begins here
- (defun emacs-process-p (pid)
- "If pid is the process ID of an emacs process, return t, else nil.
- Also returns nil if pid is nil."
- (when pid
- (let* ((cmdline-file (concat "/proc/" (int-to-string pid) "/cmdline")))
- (when (file-exists-p cmdline-file)
- (with-temp-buffer
- (insert-file-contents-literally cmdline-file)
- (goto-char (point-min))
- (search-forward "emacs" nil t)
- pid)))))
- (defadvice desktop-owner (after pry-from-cold-dead-hands activate)
- "Don't allow dead emacsen to own the desktop file."
- (when (not (emacs-process-p ad-return-value))
- (setq ad-return-value nil)))
- ;;; desktop-override-stale-locks.el ends here
- ;;;--------------------------------------------------------------------
- ;;; setup plugins
- ;;;--------------------------------------------------------------------
- (add-to-list 'load-path "~/.emacs.d/")
- (add-to-list 'load-path "~/.emacs.d/plugins")
- ;;
- ;; el-get
- ;;
- ;;-- (add-to-list 'load-path "~/.emacs.d/el-get/el-get")
- ;;--
- ;;-- (unless (require 'el-get nil t)
- ;;-- (url-retrieve
- ;;-- "https://raw.github.com/dimitri/el-get/master/el-get-install.el"
- ;;-- (lambda (s)
- ;;-- (goto-char (point-max))
- ;;-- (eval-print-last-sexp))))
- ;;--
- (add-to-list 'load-path "~/.emacs.d/el-get/el-get")
- (unless (require 'el-get nil t)
- (with-current-buffer
- (url-retrieve-synchronously
- "https://raw.github.com/dimitri/el-get/master/el-get-install.el")
- (goto-char (point-max))
- (eval-print-last-sexp)))
- (el-get 'sync)
- ;; el-get ends here
- ;;
- ;; fci
- ;;
- (setq fci-rule-width 1)
- ;; (setq fci-rule-color "darkblue")
- (setq fci-rule-color "gray5")
- (add-hook 'after-change-major-mode-hook 'fci-mode)
- (define-globalized-minor-mode global-fci-mode fci-mode (lambda () (fci-mode 1)))
- (global-fci-mode 1)
- ;;
- ;; fci ends here
- ;;
- ;;
- ;; session will conflict in daemon mode, so disabled
- ;;
- ;; (require 'session)
- ;; (add-hook 'after-init-hook 'session-initialize)
- ;; Selecting color theme can be changes using M-x color-theme-<name>
- (require 'color-theme)
- (color-theme-initialize)
- ;; setting color-theme to my favorite ;-)
- (color-theme-hober)
- ;;;
- ;;; emacs nav
- ;;;
- (nav-disable-overeager-window-splitting)
- ;; Optional: set up a quick key to toggle nav
- (global-set-key [f8] 'nav-toggle)
- ;;;
- ;;; emacs nav ends here
- ;;;
- ;;; js2-mode
- ;; After js2 has parsed a js file, we look for jslint globals decl comment ("/* global Fred, _, Harry */") and
- ;; add any symbols to a buffer-local var of acceptable global vars
- ;; Note that we also support the "symbol: true" way of specifying names via a hack (remove any ":true"
- ;; to make it look like a plain decl, and any ':false' are left behind so they'll effectively be ignored as
- ;; you can;t have a symbol called "someName:false"
- (add-hook 'js2-post-parse-callbacks
- (lambda ()
- (when (> (buffer-size) 0)
- (let ((btext (replace-regexp-in-string
- ": *true" " "
- (replace-regexp-in-string "[\n\t ]+" " " (buffer-substring-no-properties 1 (buffer-size)) t t))))
- (mapc (apply-partially 'add-to-list 'js2-additional-externs)
- (split-string
- (if (string-match "/\\* *global *\\(.*?\\) *\\*/" btext) (match-string-no-properties 1 btext) "")
- " *, *" t))
- ))))
- ;;
- ;;
- ;;
- ;;; flymake setup
- ;;;;
- ;;;; working config
- ;;;; @see http://www.thoughtspark.org/node/59
- ;;;;
- ;;;;
- (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))))
- ;; Change this path to match where you have created the jslint-wrapper
- (list "~/.emacs.d/scripts/jslint-wrapper" (list local-file))))
- (setq flymake-err-line-patterns
- (cons '("^[[:space:]]+#[[:digit:]]+ \\(.+\\)I BLAME BOTH FLYMAKE AND JSLINT.+// Line \\([[:digit:]]+\\), Pos \\([[:digit:]]+\\)$"
- nil 2 3 1)
- flymake-err-line-patterns))
- (add-to-list 'flymake-allowed-file-name-masks
- '("\\.js\\'" flymake-jslint-init)))
- (add-hook 'js2-mode-hook (lambda () (flymake-mode t)))
- ;;;;
- ;;;;
- ;;;;
- ;;;;
- ;;; js2-mode ends here
- ;;;
- ;;;
- ;;; php setting
- ;;;
- ;;;
- ;; @see http://pear.php.net/manual/en/standards.indenting.php
- (defun pear/php-mode-init()
- "Set some buffer-local variables."
- (setq case-fold-search t)
- (c-set-offset 'arglist-intro '+)
- (c-set-offset 'arglist-close '0)
- )
- (add-hook 'php-mode-hook 'pear/php-mode-init)
- ;;
- ;; mmm-mode
- ;;
- (require 'mmm-mode)
- (require 'mmm-auto)
- (setq mmm-global-mode 'maybe)
- ;; WARNING: conflicts with nav
- ;; (setq mmm-global-mode t)
- ;;;; (mmm-add-mode-ext-class 'html-mode "\\.php\\'" 'html-php)
- ;;
- ;; mmm-mode ends here
- ;;
- ;;
- ;; phpcs
- ;; @see http://pear.php.net/manual/en/package.php.php-codesniffer.reporting.php
- ;; @see http://www.illusori.co.uk/blog/2011/07/25/perl_php_static_analysis_with_emacs_flymake.html
- ;;
- (defun my-php-hook-function ()
- (set (make-local-variable 'compile-command) (format "phpcs --report=emacs --standard=PEAR %s" (buffer-file-name))))
- (add-hook 'php-mode-hook 'my-php-hook-function)
- ;;;; (require 'flyphpcs)
- ;;
- ;; phpcs ends here
- ;;
- ;;;
- ;;; php-doc
- ;;;
- ;;; Installation:
- ;; 1. Download php_manaul_en.tar.gz to local
- ;; 2. extract to certain directory
- ;; 3. add this to .emacs
- ;; (require 'php-doc nil t)
- ;; (setq php-doc-directory "/path/to/php_manual/html")
- ;; (add-hook 'php-mode-hook
- ;; (lambda ()
- ;; (local-set-key "\t" 'php-doc-complete-function)
- ;; (local-set-key (kbd "\C-c h") 'php-doc)
- ;; (set (make-local-variable 'eldoc-documentation-function)
- ;; 'php-doc-eldoc-function)
- ;; (eldoc-mode 1)))
- ;; Put this file into your load-path and the following into your ~/.emacs:
- ;; (require 'php-doc)
- ;;; Code:
- (require 'php-doc nil t)
- (setq php-doc-directory "/your/path/to/manuals/php/php-chunked-xhtml")
- (add-hook 'php-mode-hook
- (lambda ()
- (local-set-key "\t" 'php-doc-complete-function)
- (local-set-key (kbd "\C-c h") 'php-doc)
- (set (make-local-variable 'eldoc-documentation-function)
- 'php-doc-eldoc-function)
- (eldoc-mode 1)))
- (require 'php-doc)
- ;;;
- ;;; php-doc ends here
- ;;;
- ;;
- (add-hook 'php-mode-hook 'my-php-mode-stuff)
- (defun my-php-mode-stuff ()
- (local-set-key (kbd "<f1>") 'my-php-function-lookup)
- (local-set-key (kbd "C-<f1>") 'my-php-symbol-lookup))
- (defun my-php-symbol-lookup ()
- (interactive)
- (let ((symbol (symbol-at-point)))
- (if (not symbol)
- (message "No symbol at point.")
- (browse-url (concat "http://php.net/manual-lookup.php?pattern="
- (symbol-name symbol))))))
- (defun my-php-function-lookup ()
- (interactive)
- (let* ((function (symbol-name (or (symbol-at-point)
- (error "No function at point."))))
- (buf (url-retrieve-synchronously (concat "http://php.net/manual-lookup.php?pattern=" function))))
- (with-current-buffer buf
- (goto-char (point-min))
- (let (desc)
- (when (re-search-forward "<div class=\"methodsynopsis dc-description\">\\(\\(.\\|\n\\)*?\\)</div>" nil t)
- (setq desc
- (replace-regexp-in-string
- " +" " "
- (replace-regexp-in-string
- "\n" ""
- (replace-regexp-in-string "<.*?>" "" (match-string-no-properties 1)))))
- (when (re-search-forward "<p class=\"para rdfs-comment\">\\(\\(.\\|\n\\)*?\\)</p>" nil t)
- (setq desc
- (concat desc "\n\n"
- (replace-regexp-in-string
- " +" " "
- (replace-regexp-in-string
- "\n" ""
- (replace-regexp-in-string "<.*?>" "" (match-string-no-properties 1))))))))
- (if desc
- (message desc)
- (message "Could not extract function info. Press C-F1 to go the description."))))
- (kill-buffer buf)))
- ;;
- ;;;
- ;;;
- ;;; php setting ends here
- ;;;
- ;;;
- ;;
- ;; yasnippet
- ;;
- (add-to-list 'load-path
- "~/.emacs.d/plugins/yasnippet")
- (require 'yasnippet)
- ;; @see http://capitaomorte.github.com/yasnippet/snippet-organization.html
- (setq yas/root-directory
- '(
- "~/.emacs.d/plugins/yasnippet/snippets"
- ;; "~/.emacs.d/snippets/minimal-yasnippet-php-mode"
- ;; "~/.emacs.d/snippets/yas.alt/common/text-mode"
- ;; "~/.emacs.d/snippets/yasnippets-jquery"
- "~/.emacs.d/snippets/php-mode"
- "~/.emacs.d/snippets/js2-mode"
- )
- )
- (yas/global-mode 1)
- ;; (setq yas/trigger-key (kbd "<C-M-Tab>"))
- ;; (add-hook 'yas/minor-mode-on-hook
- ;; '(lambda ()
- ;; (define-key yas/minor-mode-map yas/trigger-key 'yas/expand)))
- ;;
- ;; yasnippet ends here
- ;;
- ;;
- ;; flymake-phpcs
- ;; @see https://github.com/illusori/emacs-flymake-phpcs
- ;;
- ;; If flymake_phpcs isn't found correctly, specify the full path
- (setq flymake-phpcs-command "~/.emacs.d/plugins/emacs-flymake-phpcs/bin/flymake_phpcs")
- ;; Customize the coding standard checked by phpcs
- ;; (setq flymake-phpcs-standard
- ;; "~/projects/devtools/php_codesniffer/MyCompanyStandard")
- (setq flymake-phpcs-standard
- "~/src/mypear/php/PHP/CodeSniffer/Standards/Varcheck")
- ;; Show the name of sniffs in warnings (eg show
- ;; "Generic.CodeAnalysis.VariableAnalysis.UnusedVariable" in an unused
- ;; variable warning)
- (setq flymake-phpcs-show-rule t)
- (add-to-list 'load-path
- "~/.emacs.d/plugins/emacs-flymake-phpcs")
- (require 'flymake-phpcs)
- ;;
- ;; flymake-phpcs ends here
- ;;
- ;;
- ;; erlang
- ;;
- (add-to-list 'load-path "~/lib/erlang/distel/elisp")
- (require 'distel)
- (distel-setup)
- ;; nitrogen
- (require 'nitrogen-mode)
- ;;
- ;; erlang ends here
- ;;
- ;;; setup plugins ends here
- ;;;--------------------------------------------------------------------
- ;;; some variables
- ;;;--------------------------------------------------------------------
- (setq-default indent-tabs-mode nil) ; never use tabs - only spaces
- (setq-default indicate-empty-lines t) ; show empty lines in the fringe
- (setq c-basic-offset 4) ; set indentation to four spaces
- (setq column-number-mode t) ; show column numbers on the modeline
- (setq require-final-newline t) ; automatically put newline at end of file
- ;;; some variables ends here
- ;;;--------------------------------------------------------------------
- ;;; my settings
- ;;;--------------------------------------------------------------------
- ;; Load the cua mode, provides windows like key combinations (build into emacs 22.1)
- (cua-mode t)
- ;; @see http://xahlee.org/emacs/emacs_make_modern.html
- (delete-selection-mode 1) ; delete seleted text when typing
- (global-linum-mode 1) ; display line numbers in margin. Emacs 23 only.
- ;;; (setq make-backup-files nil) ; stop creating those backup~ files
- ;;; (setq auto-save-default nil) ; stop creating those #autosave# files
- ;; hilight current line
- (global-hl-line-mode 1)
- ;; To customize the background color
- (set-face-foreground 'hl-line "gray")
- (set-face-background 'hl-line "#101010")
- ;; save desktop
- (desktop-save-mode 1)
- (add-hook 'auto-save-hook
- (lambda ()
- (desktop-save-in-desktop-dir)))
- (ido-mode t)
- (add-hook 'before-save-hook 'delete-trailing-whitespace)
- ;; (iswitchb-mode 1) ??????????????????
- (global-set-key "\C-x\C-b" 'ibuffer)
- ;; Enable
- (setq-default fill-column 72)
- ;;-- ;; whitespace-mode free of trailing whitespace and to use 80-column
- ;;-- ;; width, standard indentation
- ;;-- (setq whitespace-style '(trailing lines space-before-tab
- ;;-- indentation space-after-tab)
- ;;-- whitespace-line-column 80)
- ;; @see http://web.archive.org/web/20070114052937/http://dima-exe.ru/the-effective-emacs-translation
- (global-set-key "\C-c\C-k" 'kill-region)
- ;;
- ;; backup
- (setq
- backup-by-copying t ; don't clobber symlinks
- backup-directory-alist
- '(("." . "~/.saves")) ; don't litter my fs tree
- delete-old-versions t
- kept-new-versions 6
- kept-old-versions 2
- version-control t) ; use versioned backups
- ;; backup ends here
- ;; Toggle automatic parens pairing (Electric Pair mode)
- (electric-pair-mode t)
- ;;; my settings ends here
- ;;;--------------------------------------------------------------------
- ;;; some macro
- ;;;--------------------------------------------------------------------
- ;;; ;; duplicate line
- ;;; (defun jr-duplicate-line ()
- ;;; "EASY"
- ;;; (interactive)
- ;;; (save-excursion
- ;;; (let ((line-text (buffer-substring-no-properties
- ;;; (line-beginning-position)
- ;;; (line-end-position))))
- ;;; (move-end-of-line 1)
- ;;; (newline)
- ;;; (insert line-text))))
- ;;; (global-set-key "\C-cd" 'jr-duplicate-line)
- ;;; ;; duplicate line ends here
- ;;
- ;; duplicate-current-line-or-region
- ;; @see http://tuxicity.se/emacs/elisp/2010/03/11/duplicate-current-line-or-region-in-emacs.html
- ;;
- (defun duplicate-current-line-or-region (arg)
- "Duplicates the current line or region ARG times.
- If there's no region, the current line will be duplicated. However, if
- there's a region, all lines that region covers will be duplicated."
- (interactive "p")
- (let (beg end (origin (point)))
- (if (and mark-active (> (point) (mark)))
- (exchange-point-and-mark))
- (setq beg (line-beginning-position))
- (if mark-active
- (exchange-point-and-mark))
- (setq end (line-end-position))
- (let ((region (buffer-substring-no-properties beg end)))
- (dotimes (i arg)
- (goto-char end)
- (newline)
- (insert region)
- (setq end (point)))
- (goto-char (+ origin (* (length region) arg) arg)))))
- (global-set-key (kbd "\C-cd") 'duplicate-current-line-or-region)
- (global-set-key (kbd "C-c a") 'duplicate-current-line-or-region)
- (global-set-key [f5] 'duplicate-current-line-or-region)
- (global-set-key (kbd "<C-tab>") 'indent-according-to-mode)
- (global-set-key (kbd "<C-M-tab>") 'indent-region)
- (global-set-key [f2] 'comment-region)
- ;;
- ;; duplicate-current-line-or-region ends here
- ;;
- ;;
- ;; ctags
- ;;
- (setq path-to-ctags "/usr/bin/ctags") ;; <- your ctags path here
- (defun create-tags (dir-name)
- "Create tags file."
- (interactive "DDirectory: ")
- (shell-command
- (format "%s -f %s/TAGS -e -R %s" path-to-ctags dir-name (directory-file-name dir-name)))
- )
- ;;
- ;; ctags ends here
- ;;
- ;;
- (add-to-list 'load-path "~/.emacs.d/")
- (require 'auto-complete-config)
- (ac-config-default)
- ;;
- (defun get-erl-man ()
- (interactive)
- (let* ((man-path "/your/path/to/src/docs/pman/php.net/")
- (man-args (format "-M %s %s" man-path (current-word))))
- (man man-args)))
- (global-set-key [(f6)] (lambda () (interactive) (get-erl-man)))
- ;;
- ;; auto-comlpete
- ;;
- ;; (ac-set-trigger-key "C-TAB")
- ;; (setq ac-auto-start nil)
- ;; (define-key ac-mode-map (kbd "<C-tab>") 'auto-complete)
- ;; Show 0.8 second later
- (setq ac-auto-show-menu 0.8)
- ;;
- ;; auto-complete ends here
- ;;
- ;;; some macro ends here
- (server-start)
- (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.
- )
- (put 'upcase-region 'disabled nil)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement