view dotemacs.el @ 162:5c13462f99d7

.php: use web-mode instead of default php-mode
author Jordi Gutiérrez Hermoso <jordigh@octave.org>
date Sun, 22 Oct 2017 09:07:09 -0400
parents b192a20c262a
children 406853db771f
line wrap: on
line source

(add-to-list 'load-path "~/.emacs.d/packages/")
(package-initialize)

(defalias 'perl-mode 'cperl-mode)

(require 'legalese)

(require 'rainbow-mode)

(require 'stripes)

(require 'matlab)

(require 'tabbar)

(require 'bar-cursor)

(require 'fill-column-indicator)

(require 'adaptive-wrap)

(require 'rpm-spec-mode)

(require 'mediawiki)

(require 'd-mode)

(require 'sdlang-mode)

(require 'fish-mode)

;; Let's highlight the current line in windows
(global-hl-line-mode)

;; I think I like the idea of the cursor being more indicative of
;; where the point is.
(bar-cursor-mode)

;; Show where the fill column is
(fci-mode)

;(require 'erc-highlight-mode)
(setq erc-input-line-position -2)

;; Use org-mode to write blogthings
(setq load-path (cons "~/.emacs.d/packages/org2blog" load-path))
(require 'org2blog)

(setq org2blog-server-url "http://jordi.inversethought.com/xmlrpc.php"
      org2blog-server-user "jordigh"
      org2blog-server-weblog-id "")

(require 'saveplace)
(setq-default save-place t)

(server-start)

;; I want tramp to obey the $PATH that is set on the remote host
(require 'tramp)
(add-to-list 'tramp-remote-path 'tramp-own-remote-path)

;; wtf is this crap? begone!
(setq transient-mark-mode nil)

(global-set-key (kbd "C-S-n") 'tabbar-forward-tab)
(global-set-key (kbd "C-S-p") 'tabbar-backward-tab)
(global-set-key  (kbd "C-c C-S-n") 'tabbar-forward-group)
(global-set-key  (kbd "C-c C-S-p") 'tabbar-backward-group)

(global-set-key (kbd "C-S-j") 'windmove-down)
(global-set-key (kbd "C-S-k") 'windmove-up)
(global-set-key (kbd "C-S-h") 'windmove-left)
(global-set-key (kbd "C-S-l") 'windmove-right)

(global-set-key (kbd "C-x <SPC>") 'gud-break)
(global-set-key (kbd "M-<down>") 'gud-next)
(global-set-key (kbd "M-<right>") 'gud-step)
(global-set-key (kbd "M-<left>") 'gud-finish)
(global-set-key (kbd "M-<RET>") 'gud-cont)
(global-unset-key (kbd "C-x <DEL>"))
(global-set-key (kbd "C-x <DEL>") 'gud-remove)
(global-unset-key (kbd "C-x C-z"))
(global-set-key (kbd "C-x C-z") 'gud-stop-subjob)

;; Like pdb's "until"
(global-set-key (kbd "C-<return>")
 (lambda () (interactive)
   (progn
     (gud-tbreak (line-number-at-pos))
     (gud-cont (line-number-at-pos)))))

;; web-mode doesn't seem to have another way of figuring out which
;; engine to use, but Django templates is all I care about for now.
(setq web-mode-engines-alist
      '(("django"    . "\\.html\\'"))

)

;;; H/T Stefan Monnier
(defun unfill-paragraph (&optional region)
  "Takes a multi-line paragraph and makes it into a single line of text."
  (interactive (progn (barf-if-buffer-read-only) '(t)))
  (let ((fill-column (point-max)))
    (fill-paragraph nil region)))

;;; http://stackoverflow.com/a/23382008
(require 'ansi-color)
(defun display-ansi-colors ()
  (interactive)
  (ansi-color-apply-on-region (point-min) (point-max)))

;;; H/T Tom Tromey
(defun insert-filename-and-line-at-point (path)
  "Just insert the full absolute pathname including the line
number at point, like in gcc error messages."
  (interactive (progn (barf-if-buffer-read-only) '(t)))
  (let ((fname . (buffer-file-name)))
    (insert fname ":" (int-to-string (line-number-at-pos)))))

;; The default selection keys for company-mode are M-n and M-p, eww.
(require 'company)
(define-key company-active-map (kbd "C-p") 'company-select-previous-or-abort)
(define-key company-active-map (kbd "C-n") 'company-select-next-or-abort)

(global-set-key (kbd "M-Q") 'unfill-paragraph)

;; Only killing the current buffer is useful (thanks to madpickle of #emacs)
(global-set-key (kbd "C-x k")
		(lambda () (interactive) (kill-buffer (current-buffer))))

;; I never use this function, and I frequently typo it when trying to
;; hit C-x C-f
(global-unset-key (kbd "C-x f"))

;; Make dired visit directory or file in the same buffer
(put 'dired-find-alternate-file 'disabled nil)
(add-hook 'dired-mode-hook
          (lambda ()
            (local-set-key (kbd "<RET>") 'dired-find-alternate-file)))

;; I want <RET> to indent the next line in python-mode. This swaps
;; the standard definitions of <RET> and C-j.
(add-hook 'python-mode-hook
          (lambda ()
            (local-set-key (kbd "<RET>") 'newline-and-indent)
            (local-set-key (kbd "C-j") 'newline)))

(setq auto-mode-alist
      (append
       '(
         ("\\.m\\'" . octave-mode)
         ("\\.eml\\'" . mail-mode)
         ("\\.pro\\'" . conf-mode) ;; Qt project files
         ("\\.php\\'" . web-mode) ;; Default php mode isn't as good
         ("\\.?hgrc\\'"  . conf-mode)
         ("\\.spec\\'" . rpm-spec-mode)
         ("evo[A-Z0-9]\\{6\\}\\'" . mail-mode))
       auto-mode-alist))

;; Scroll smoothly
(setq scroll-step 1000)
(setq scroll-conservatively 1000)

;; This ido thing looks interesting...
(ido-mode 1)

(setq default-major-mode 'text-mode)
(global-unset-key "\C-z")

;; po-mode seems to have forgotten to bind this key, because it does
;; bind C-_
(add-hook 'po-mode-hook
          (lambda ()
            (local-set-key (kbd "C-/") 'po-undo)))

;; Don't like it when several windows open upon emacs startup
;; (Thanks theseb of #emacs)
(add-hook 'window-setup-hook 'delete-other-windows)
(add-to-list 'same-window-buffer-names "*Buffer List*")

;; Set auto-fill for all modes
;(setq-default auto-fill-function 'do-auto-fill)

;ibuffer is the only decent one
(global-set-key (kbd "C-x C-b") 'ibuffer)

;Make GUD put output in a different buffer
(setq gdb-separate-io t)

;; Highlight "FIXME: and TODO:"
(font-lock-add-keywords
 'c-mode
 '(("\\<\\(FIXME\\)" 1 font-lock-warning-face t)))

(font-lock-add-keywords
 'c++-mode
 '(("\\<\\(FIXME\\):" 1 font-lock-warning-face t)))

(font-lock-add-keywords
 'c-mode
 '(("\\<\\(TODO\\):" 1 font-lock-warning-face t)))

(font-lock-add-keywords
 'c++-mode
 '(("\\<\\(TODO\\):" 1 font-lock-warning-face t)))

;; Let auto-fill end lines with a full stop.
(setq sentence-end-double-space nil)

;; Don't let ediff open a new frame
(setq ediff-window-setup-function 'ediff-setup-windows-plain)

;; Don't like stuff to indent when I don't hit <TAB>
(setq electric-indent-mode nil)

;; Menus are for wimps
(menu-bar-mode -1)

(put 'narrow-to-region 'disabled nil)

;;; Inserts a relative pathname interactively
(defun insert-relative-path (path)
  (interactive (list (read-file-name "Path to insert relatively: ")))
  (insert (file-relative-name path default-directory)))

; Add cmake listfile names to the mode list.
(setq auto-mode-alist
      (append
       '(("CMakeLists\\.txt\\'" . cmake-mode))
       '(("\\.cmake\\'" . cmake-mode))
       auto-mode-alist))

(defun set-tab-width (width)
  (interactive "nSet tab width: ")
  (setq tab-width width))

;; "Fix" the horrible asn1-mode mess
(add-hook 'asn1-mode-hook
	  (lambda ()
	    (setq indent-line-function #'indent-relative)
	    (setq case-fold-search t)))

;; vc-mode can't work with all of my hg customisations, but this
;; undoes most of them
(setenv "HGPLAIN" "1")

;; What it says on the tin
(add-hook 'mail-mode-hook 'turn-on-auto-fill)

;; Some info vi-like keybindings
(add-hook 'Info-mode-hook
	  (lambda ()
	    (local-unset-key (kbd "l"))
	    (local-set-key (kbd ";") 'Info-history-back)
	    (local-set-key (kbd "h") 'backward-char)
	    (local-set-key (kbd "l") 'forward-char)
	    (local-set-key (kbd "j") 'next-line)
	    (local-set-key (kbd "k") 'previous-line)
	    (local-set-key (kbd "/") 'Info-search)))

;; moar vi
(add-hook 'doc-view-mode-hook
	  (lambda ()
	    (local-unset-key (kbd "k"))
	    (local-set-key (kbd "j") 'doc-view-next-line-or-next-page)
	    (local-set-key (kbd "k") 'doc-view-previous-line-or-previous-page)
	    (local-set-key (kbd "h")  'image-backward-hscroll)
	    (local-set-key (kbd "l")  'image-forward-hscroll)))

(setq doc-view-continuous t)

;; Something seems to clobber whitespace-mode, this should fix it
(whitespace-toggle-options 'whitespace-style)

(defun hide-ctrl-M ()
  "Hides the annoying '^M' showing up in files containing mixed
UNIX and DOS line endings."
  (interactive)
  (setq buffer-display-table (make-display-table))
  (aset buffer-display-table ?\^M []))

(add-hook  'magit-mode-hook
	   (lambda ()
	     ;; I always run magit side-by-side to the code I'm reading
	     (local-set-key (kbd "<RET>") (lambda ()
					    (interactive)
					    (magit-visit-item t)))))

(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.
 '(LaTeX-indent-level 2)
 '(LaTeX-item-indent 0)
 '(TeX-PDF-mode t)
 '(TeX-brace-indent-level 2)
 '(TeX-debug-bad-boxes t)
 '(TeX-debug-warnings t)
 '(TeX-display-help nil)
 '(TeX-newline-function (quote reindent-then-newline-and-indent))
 '(TeX-output-view-style
   (quote
    (("^dvi$"
      ("^landscape$" "^pstricks$\\|^pst-\\|^psfrag$")
      "%(o?)dvips -t landscape %d -o && gv %f")
     ("^dvi$" "^pstricks$\\|^pst-\\|^psfrag$" "%(o?)dvips %d -o && gv %f")
     ("^dvi$"
      ("^a4\\(?:dutch\\|paper\\|wide\\)\\|sem-a4$" "^landscape$")
      "%(o?)xdvi %dS -paper a4r -s 0 %d")
     ("^dvi$" "^a4\\(?:dutch\\|paper\\|wide\\)\\|sem-a4$" "%(o?)xdvi %dS -paper a4 %d")
     ("^dvi$"
      ("^a5\\(?:comb\\|paper\\)$" "^landscape$")
      "%(o?)xdvi %dS -paper a5r -s 0 %d")
     ("^dvi$" "^a5\\(?:comb\\|paper\\)$" "%(o?)xdvi %dS -paper a5 %d")
     ("^dvi$" "^b5paper$" "%(o?)xdvi %dS -paper b5 %d")
     ("^dvi$" "^letterpaper$" "%(o?)xdvi %dS -paper us %d")
     ("^dvi$" "^legalpaper$" "%(o?)xdvi %dS -paper legal %d")
     ("^dvi$" "^executivepaper$" "%(o?)xdvi %dS -paper 7.25x10.5in %d")
     ("^dvi$" "." "%(o?)xdvi %dS %d")
     ("^pdf$" "." "evince %o %(outpage)")
     ("^html?$" "." "netscape %o"))))
 '(TeX-view-program-selection
   (quote
    (((output-dvi style-pstricks)
      "dvips and gv")
     (output-dvi "Evince")
     (output-pdf "Evince")
     (output-html "xdg-open"))))
 '(add-log-mailing-address "jordigh@octave.org")
 '(auto-compression-mode t nil (jka-compr))
 '(c-offsets-alist (quote ((substatement-open . 0) (innamespace . 0))))
 '(case-fold-search t)
 '(column-number-mode t)
 '(comint-input-autoexpand (quote history))
 '(comint-move-point-for-output (quote all))
 '(comint-prompt-read-only t)
 '(comint-scroll-to-bottom-on-input (quote all))
 '(compilation-scroll-output t)
 '(confirm-kill-emacs (quote yes-or-no-p))
 '(cperl-auto-newline nil)
 '(cperl-close-paren-offset 0)
 '(cperl-electric-backspace-untabify nil)
 '(cperl-highlight-variables-indiscriminately t)
 '(cperl-merge-trailing-else nil)
 '(current-language-environment "UTF-8")
 '(debian-changelog-full-name "Jordi Gutiérrez Hermoso")
 '(debian-changelog-mailing-address "jordigh@octave.org")
 '(default-input-method "latin-1-prefix")
 '(ecb-options-version "2.32")
 '(ecb-tip-of-the-day nil)
 '(ediff-split-window-function (quote split-window-horizontally))
 '(elpy-interactive-python-command "ipython")
 '(elpy-modules
   (quote
    (elpy-module-company elpy-module-eldoc elpy-module-flymake elpy-module-pyvenv elpy-module-yasnippet elpy-module-sane-defaults)))
 '(elpy-rpc-timeout 5)
 '(erc-input-line-position 0 t)
 '(erc-modules
   (quote
    (highlight-nicknames scrolltobottom completion autojoin button fill irccontrols list match menu move-to-prompt netsplit networks noncommands readonly ring stamp track)))
 '(gdb-max-frames 1000)
 '(global-font-lock-mode t nil (font-lock))
 '(gud-pdb-command-name "pdb")
 '(ido-auto-merge-work-directories-length -1)
 '(indent-tabs-mode nil)
 '(inhibit-startup-buffer-menu t)
 '(inhibit-startup-screen t)
 '(jde-jdk-registry (quote (("1.6.0" . "/usr/lib/jvm/java-6-openjdk"))))
 '(js2-auto-indent-flag nil)
 '(js2-bounce-indent-flag nil)
 '(js2-enter-indents-newline nil)
 '(js2-mirror-mode nil)
 '(legalese-default-author "Jordi Gutiérrez Hermoso")
 '(legalese-default-copyright "Jordi Gutiérrez Hermoso <jordigh@octave.org>")
 '(make-backup-files nil)
 '(package-archives
   (quote
    (("melpa-stable" . "https://stable.melpa.org/packages/")
     ("gnu" . "http://elpa.gnu.org/packages/"))))
 '(package-selected-packages
   (quote
    (magit js2-mode yaml-mode web-mode undo-tree nginx-mode json-mode jade-mode idomenu haml-mode goto-last-change flymake-haml elpy dockerfile-mode)))
 '(safe-local-variable-values
   (quote
    ((encoding . utf-8)
     (eval when
           (and
            (buffer-file-name)
            (string-match-p "\\.h\\'"
                            (buffer-file-name))
            (not
             (string-match-p "/gnulib/"
                             (buffer-file-name))))
           (c++-mode)
           (c-set-style "gnu"))
     (eval when
           (string-match "\\.in\\'"
                         (buffer-file-name))
           (html-mode))
     (eval when
           (string-match "\\.h\\'"
                         (buffer-file-name))
           (unless
               (string-match "/gnulib/"
                             (buffer-file-name))
             (c++-mode)
             (c-set-style "gnu")))
     (py-indent-offset . 4)
     (eval when
           (string-match "\\.h\\'"
                         (buffer-file-name))
           (c++-mode)
           (c-set-style "gnu")))))
 '(savehist-mode t nil (savehist))
 '(show-paren-mode t)
 '(tab-width 2)
 '(tabbar-mode t nil (tabbar))
 '(text-mode-hook (quote (text-mode-hook-identify)))
 '(tool-bar-mode nil)
 '(tramp-default-method "ssh")
 '(tramp-remote-process-environment
   (quote
    ("HISTFILE=$HOME/.tramp_history" "HISTSIZE=1" "LC_ALL=C" "TERM=dumb" "EMACS=t" "INSIDE_EMACS='24.3.1,tramp:2.2.6-24.3'" "CDPATH=" "HISTORY=" "MAIL=" "MAILCHECK=" "MAILPATH=" "PAGER=\"\"" "autocorrect=" "HGPLAIN=1" "correct=")))
 '(transient-mark-mode nil)
 '(uniquify-buffer-name-style (quote forward) nil (uniquify))
 '(vc-follow-symlinks nil)
 '(w3m-default-display-inline-images t)
 '(w3m-use-cookies t)
 '(web-mode-markup-indent-offset 4)
 '(x-select-enable-clipboard t)
 '(x-select-enable-primary 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.
 '(default ((t (:inherit nil :stipple nil :background "grey20" :foreground "white" :inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant normal :weight normal :height 98 :width normal :foundry "unknown" :family "Liberation Mono"))))
 '(diff-added ((t (:foreground "lime green"))))
 '(diff-changed ((t (:foreground "orange"))))
 '(diff-file-header ((((class color) (background light)) (:background "lightblue" :bold t))))
 '(diff-header ((nil (:foreground "skyblue"))))
 '(diff-refine-added ((t (:inherit diff-refine-change :background "#114411"))))
 '(diff-refine-change ((((class color) (min-colors 88) (background dark)) (:background "navyblue"))))
 '(diff-refine-removed ((t (:inherit diff-refine-change :background "#441111"))))
 '(diff-removed ((t (:foreground "orangered"))))
 '(ecb-tag-header-face ((((class color) (background dark)) (:background "DarkGreen"))))
 '(ediff-even-diff-B ((t (:background "Grey" :foreground "black"))))
 '(ediff-odd-diff-A ((t (:background "Grey" :foreground "black"))))
 '(ediff-odd-diff-C ((t (:background "Grey" :foreground "black"))))
 '(erc-input-face ((t (:foreground "yellow"))))
 '(erc-my-nick-face ((t (:foreground "lightblue" :weight bold))))
 '(erc-notice-face ((t (:foreground "lightgreen" :weight bold))))
 '(flymake-errline ((t (:background "#332525"))))
 '(flymake-warnline ((t (:background "#404033"))))
 '(highlight ((((class color) (min-colors 88) (background dark)) (:background "#555"))))
 '(magit-diff-add ((((class color) (background dark)) (:foreground "lime green"))))
 '(magit-diff-del ((t (:inherit diff-removed))))
 '(mode-line ((t (:background "#C90" :foreground "#000000" :box (:line-width -1 :style released-button)))))
 '(monky-header ((t (:background "#666"))))
 '(rpm-spec-package-face ((((class color) (background dark)) (:foreground "#F88"))))
 '(rpm-spec-tag-face ((((class color) (background dark)) (:foreground "light blue"))))
 '(rst-level-1-face ((t (:background "grey10"))) t)
 '(rst-level-2-face ((t (:background "grey10"))) t)
 '(rst-level-3-face ((t (:background "grey10"))) t)
 '(show-ws-tab ((t (:background "Black"))))
 '(stripes-face ((t (:background "#444")))))