Merge branch 'master' of github.com:bbatsov/prelude

This commit is contained in:
Bozhidar Batsov 2014-08-12 12:54:54 +03:00
commit e20088d581
6 changed files with 46 additions and 18 deletions

View file

@ -286,7 +286,7 @@ Keybinding | Description
<kbd>C-c n</kbd> | Fix indentation in buffer and strip whitespace. <kbd>C-c n</kbd> | Fix indentation in buffer and strip whitespace.
<kbd>C-c f</kbd> | Open recently visited file. <kbd>C-c f</kbd> | Open recently visited file.
<kbd>C-M-\\</kbd> | Indent region (if selected) or the entire buffer. <kbd>C-M-\\</kbd> | Indent region (if selected) or the entire buffer.
<kbd>C-c u</kbd> | Open URL in your default browser. <kbd>C-c u</kbd> | Open a new buffer containing the contents of URL.
<kbd>C-c e</kbd> | Eval a bit of Emacs Lisp code and replace it with its result. <kbd>C-c e</kbd> | Eval a bit of Emacs Lisp code and replace it with its result.
<kbd>C-c s</kbd> | Swap two active windows. <kbd>C-c s</kbd> | Swap two active windows.
<kbd>C-c D</kbd> | Delete current file and buffer. <kbd>C-c D</kbd> | Delete current file and buffer.

View file

@ -266,8 +266,11 @@ there's a region, all lines that region covers will be duplicated."
(url (read-from-minibuffer "URL: " default))) (url (read-from-minibuffer "URL: " default)))
(switch-to-buffer (url-retrieve-synchronously url)) (switch-to-buffer (url-retrieve-synchronously url))
(rename-buffer url t) (rename-buffer url t)
(cond ((search-forward "<?xml" nil t) (nxml-mode)) (goto-char (point-min))
((search-forward "<html" nil t) (html-mode))))) (re-search-forward "^$")
(delete-region (point-min) (point))
(delete-blank-lines)
(set-auto-mode)))
(defun prelude-cleanup-buffer-or-region () (defun prelude-cleanup-buffer-or-region ()
"Cleanup a region if selected, otherwise the whole buffer." "Cleanup a region if selected, otherwise the whole buffer."
@ -303,11 +306,10 @@ buffer is not visiting a file."
(defadvice ido-find-file (after find-file-sudo activate) (defadvice ido-find-file (after find-file-sudo activate)
"Find file as root if necessary." "Find file as root if necessary."
(unless (or (equal major-mode 'dired-mode) (unless (or (tramp-tramp-file-p buffer-file-name)
(and (buffer-file-name) (equal major-mode 'dired-mode)
(not (file-exists-p (file-name-directory (buffer-file-name))))) (not (file-exists-p (file-name-directory buffer-file-name)))
(and (buffer-file-name) (file-writable-p buffer-file-name))
(file-writable-p buffer-file-name)))
(find-alternate-file (concat "/sudo:root@localhost:" buffer-file-name)))) (find-alternate-file (concat "/sudo:root@localhost:" buffer-file-name))))
(defun prelude-start-or-switch-to (function buffer-name) (defun prelude-start-or-switch-to (function buffer-name)
@ -371,9 +373,9 @@ Doesn't mess with special buffers."
(defun prelude-create-scratch-buffer () (defun prelude-create-scratch-buffer ()
"Create a new scratch buffer." "Create a new scratch buffer."
(interactive) (interactive)
(let ((buf (get-buffer-create (generate-new-buffer-name "*scratch*")))) (let ((buf (generate-new-buffer "*scratch*")))
(set-buffer-major-mode buf) (switch-to-buffer buf)
(switch-to-buffer buf))) (funcall initial-major-mode)))
(defvar prelude-tips (defvar prelude-tips
'("Press <C-c o> to open a file with external program." '("Press <C-c o> to open a file with external program."

View file

@ -48,6 +48,9 @@
(setq evil-insert-state-cursor '("gray" bar)) (setq evil-insert-state-cursor '("gray" bar))
(setq evil-motion-state-cursor '("gray" box)) (setq evil-motion-state-cursor '("gray" box))
;; prevent esc-key from translating to meta-key in terminal mode
(setq evil-esc-delay 0)
(evil-mode 1) (evil-mode 1)
(global-evil-surround-mode 1) (global-evil-surround-mode 1)

View file

@ -40,7 +40,8 @@
(defun prelude-haskell-mode-defaults () (defun prelude-haskell-mode-defaults ()
(subword-mode +1) (subword-mode +1)
(turn-on-haskell-doc-mode) (turn-on-haskell-doc-mode)
(turn-on-haskell-indentation)) (turn-on-haskell-indentation)
(interactive-haskell-mode +1))
(setq prelude-haskell-mode-hook 'prelude-haskell-mode-defaults) (setq prelude-haskell-mode-hook 'prelude-haskell-mode-defaults)

View file

@ -32,14 +32,25 @@
;;; Code: ;;; Code:
(prelude-require-packages '(auctex)) (prelude-require-packages '(auctex cdlatex))
(require 'smartparens-latex) (require 'smartparens-latex)
;; for case
(require 'cl)
(eval-after-load "company" (eval-after-load "company"
'(progn '(progn
(prelude-require-packages '(company-auctex)) (prelude-require-packages '(company-auctex))
(company-auctex-init))) (company-auctex-init)))
(defcustom prelude-latex-fast-math-entry 'LaTeX-math-mode
"Method used for fast math symbol entry in LaTeX."
:link '(function-link :tag "AUCTeX Math Mode" LaTeX-math-mode)
:link '(emacs-commentary-link :tag "CDLaTeX" "cdlatex.el")
:group 'prelude
:type '(choice (const :tag "None" nil)
(const :tag "AUCTeX Math Mode" LaTeX-math-mode)
(const :tag "CDLaTeX" cdlatex)))
;; AUCTeX configuration ;; AUCTeX configuration
(setq TeX-auto-save t) (setq TeX-auto-save t)
(setq TeX-parse-self t) (setq TeX-parse-self t)
@ -65,7 +76,10 @@
"Default Prelude hook for `LaTeX-mode'." "Default Prelude hook for `LaTeX-mode'."
(turn-on-auto-fill) (turn-on-auto-fill)
(abbrev-mode +1) (abbrev-mode +1)
(smartparens-mode +1)) (smartparens-mode +1)
(case prelude-latex-fast-math-entry
(LaTeX-math-mode (LaTeX-math-mode 1))
(cdlatex (turn-on-cdlatex))))
(setq prelude-latex-mode-hook 'prelude-latex-mode-defaults) (setq prelude-latex-mode-hook 'prelude-latex-mode-defaults)

View file

@ -38,18 +38,26 @@
(require 'utop) (require 'utop)
(require 'merlin) (require 'merlin)
(add-hook 'tuareg-mode-hook 'tuareg-imenu-set-imenu)
(setq auto-mode-alist (setq auto-mode-alist
(append '(("\\.ml[ily]?\\'" . tuareg-mode) (append '(("\\.ml[ily]?\\'" . tuareg-mode)
("\\.topml\\'" . tuareg-mode)) ("\\.topml\\'" . tuareg-mode))
auto-mode-alist)) auto-mode-alist))
(autoload 'utop-setup-ocaml-buffer "utop" "Toplevel for OCaml" t)
(add-hook 'tuareg-mode-hook 'utop-setup-ocaml-buffer) (add-hook 'tuareg-mode-hook 'utop-setup-ocaml-buffer)
(add-hook 'tuareg-mode-hook 'merlin-mode) (add-hook 'tuareg-mode-hook 'merlin-mode)
(add-hook 'tuareg-mode-hook (lambda ()
(progn
(define-key tuareg-mode-map (kbd "C-c C-s")
'utop))))
;; Setup merlin completions company is used by default in prelude
(add-to-list 'company-backends 'merlin-company-backend)
;; But merlin also offers support for autocomplete, uncomment this next line
;; to activate it.
;; (setq merlin-use-auto-complete-mode t)
(setq utop-command "opam config exec \"utop -emacs\"" (setq utop-command "opam config exec \"utop -emacs\""
merlin-error-after-save nil) merlin-error-after-save nil)