Last active
November 13, 2018 15:03
-
-
Save cawka/13ea228dd4d7a32261c2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; Make sure history of command and files is remembered | |
;; ____________________________________________________________________________ | |
;; Aquamacs custom-file warning: | |
;; Warning: After loading this .emacs file, Aquamacs will also load | |
;; customizations from `custom-file' (customizations.el). Any settings there | |
;; will override those made here. | |
;; Consider moving your startup settings to the Preferences.el file, which | |
;; is loaded after `custom-file': | |
;; ~/Library/Preferences/Aquamacs Emacs/Preferences | |
;; _____________________________________________________________________________ | |
(savehist-mode t) | |
;; Disable backup files | |
(setq make-backup-files nil) | |
;; Add `~/.emacs.d' to search path | |
(add-to-list 'load-path "~/.emacs.d/lisp") | |
;; ;; Configure ELPA package repositories | |
(setq package-archives '(("gnu" . "http://elpa.gnu.org/packages/") | |
("marmalade" . "http://marmalade-repo.org/packages/") | |
("melpa" . "http://melpa.milkbox.net/packages/") | |
("orgmode" . "http://orgmode.org/elpa/"))) | |
(setq package-enable-at-startup nil) | |
(package-initialize) | |
;; Remove welcome window | |
(setq-default inhibit-startup-screen t) | |
;; Compiling tex documents to PDF by default | |
;; (setq TeX-PDF-mode t) | |
;; Symbol highlighting | |
(require 'highlight-symbol) | |
;; Line numbers | |
(global-linum-mode 1) | |
;; Disable tabs | |
(setq-default indent-tabs-mode nil) | |
(defun move-and-highlight-symbol-at-point(event) | |
"Change cursor position and highlight symbol at point" | |
(interactive "e") | |
(mouse-set-point event) | |
(highlight-symbol-at-point)) | |
(global-set-key [(mouse-4)] 'move-and-highlight-symbol-at-point) | |
(global-set-key [(C-s-mouse-1)] 'move-and-highlight-symbol-at-point) | |
;; Highlilght whitespace | |
(require 'whitespace) | |
(setq whitespace-style '(face empty tabs lines-tail trailing)) | |
(setq whitespace-line-column 100) | |
;; Line commenting | |
;; Original idea from | |
;; http://www.opensubscriber.com/message/emacs-devel@gnu.org/10971693.html | |
(defun comment-dwim-line (&optional arg) | |
"Replacement for the comment-dwim command. | |
If no region is selected and current line is not blank, then comment current line. | |
Replaces default behaviour of comment-dwim, when it inserts comment at the end of the line." | |
(interactive "*P") | |
(comment-normalize-vars) | |
(if (not (region-active-p)) | |
(comment-or-uncomment-region (line-beginning-position) (line-end-position)) | |
(comment-dwim arg) | |
) | |
(setq deactivate-mark nil)) | |
(global-set-key "\M-;" 'comment-dwim-line) ;; compatible to terminal emacs | |
(global-set-key (kbd "A-/") 'comment-dwim-line) ;; for aquamacs | |
;; Hacking GNU c/c++ style | |
;; After trying my ass off, this is the only solution to add | |
;; "innamespace -" after local variables (style) is applied to a file | |
(c-add-style "gnu" | |
'( | |
(c-basic-offset . 2) | |
(c-comment-only-line-offset 0 . 0) | |
(c-hanging-braces-alist | |
(substatement-open before after) | |
(arglist-cont-nonempty)) | |
(c-offsets-alist | |
(innamespace . -) | |
(statement-block-intro . +) | |
(knr-argdecl-intro . 5) | |
(substatement-open . +) | |
(substatement-label . 0) | |
(label . 0) | |
(statement-case-open . +) | |
(statement-cont . +) | |
(arglist-intro . c-lineup-arglist-intro-after-paren) | |
(arglist-close . c-lineup-arglist) | |
(inline-open . 0) | |
(brace-list-open . +) | |
(topmost-intro-cont first c-lineup-topmost-intro-cont c-lineup-gnu-DEFUN-intro-cont)) | |
(c-special-indent-hook . c-gnu-impose-minimum) | |
(c-block-comment-prefix . "") | |
) | |
) | |
(autoload 'flyspell-mode "flyspell" "On-the-fly spelling checker." t) | |
(defun my-guess-tex-master() | |
(save-excursion | |
(let ((files (directory-files (file-name-directory (buffer-file-name)) nil "^[^\.].*\.tex$" nil)) | |
(done nil)) | |
(goto-char (point-min)) | |
(if (re-search-forward "documentclass" nil t) | |
(setq done (buffer-file-name))) | |
(while (and files (not done)) | |
(let ((file (pop files))) | |
(save-excursion | |
(message file) | |
(with-current-buffer (find-file file) | |
(goto-char (point-min)) | |
(if (re-search-forward "documentclass" nil t) | |
(setq done file)) | |
) | |
) | |
) | |
) | |
(if done | |
done (file-name-nondirectory (buffer-file-name)) | |
) | |
) | |
) | |
) | |
(defun my-latex-mode-hook() | |
(turn-on-flyspell) | |
(set-word-wrap) | |
(setq word-wrap t) | |
(auto-fill-mode -1) | |
(setq TeX-master (my-guess-tex-master)) | |
) | |
;; (setq-default TeX-master nil) | |
;; (require 'guess-tex-master) | |
(add-hook 'TeX-mode-hook 'my-latex-mode-hook) | |
;; (add-hook 'TeX-mode-hook 'my-text-mode-hook) | |
(defun my-text-mode-hook() | |
(turn-on-flyspell) | |
(set-word-wrap) | |
(setq word-wrap t) | |
(auto-fill-mode -1) | |
) | |
(add-hook 'text-mode-hook 'my-text-mode-hook) | |
(add-hook 'rst-mode-hook 'my-text-mode-hook) | |
(add-hook 'markdown-mode-hook 'my-text-mode-hook) | |
(add-hook 'change-log-mode-hook (lambda () | |
(flyspell-mode -1) | |
)) | |
(add-hook 'c-mode-common-hook (lambda () | |
(flyspell-prog-mode) | |
(c-set-style "gnu") | |
(local-set-key (kbd "RET") 'newline-and-indent) | |
(setq comment-start "//" comment-end "") | |
(setq-default indent-tabs-mode nil) | |
(whitespace-mode) | |
;; (doxymacs-mode) | |
;; (add-to-list 'write-file-functions 'delete-trailing-whitespace) | |
)) | |
(require 'smex) ; Not needed if you use package.el | |
(smex-initialize) ; Can be omitted. This might cause a (minimal) delay | |
; when Smex is auto-initialized on its first run. | |
(global-set-key (kbd "M-x") 'smex) | |
(global-set-key (kbd "M-X") 'smex-major-mode-commands) | |
;; This is your old M-x. | |
(global-set-key (kbd "C-c C-c M-x") 'execute-extended-command) | |
(require 'ido) | |
(ido-mode t) | |
(setq ido-enable-flex-matching t) | |
;; (setq ido-everywhere t) | |
;; (ido-mode t) | |
(require 'ido-vertical-mode) | |
(ido-vertical-mode t) | |
;; cedet | |
;; (semantic-mode 1) | |
;; (global-ede-mode 1) | |
;; load eassist | |
(require 'eassist) | |
(defun toggle-camelcase-underscores () | |
"Toggle between camcelcase and underscore notation for the symbol at point." | |
(interactive) | |
(save-excursion | |
(let* ((bounds (bounds-of-thing-at-point 'symbol)) | |
(start (car bounds)) | |
(end (cdr bounds)) | |
(currently-using-underscores-p (progn (goto-char start) | |
(re-search-forward "_" end t)))) | |
(if currently-using-underscores-p | |
(progn | |
(downcase-region start end) | |
(upcase-initials-region start end) | |
(replace-string "_" "" nil start end) | |
;; (downcase-region start (1+ start)) | |
) | |
(progn | |
(replace-regexp "\\([A-Z]\\)" "_\\1" nil (1+ start) end) | |
(downcase-region start end) | |
) | |
)))) | |
;; to allow switching between source and headers | |
(add-hook 'c-mode-common-hook | |
(lambda() | |
(local-set-key (kbd "C-c o") 'eassist-switch-h-cpp) | |
(local-set-key (kbd "M-o") 'eassist-switch-h-cpp) | |
(local-set-key (kbd "M-m") 'eassist-list-methods))) | |
;; (defun my-cedet-hook () | |
;; (local-set-key [(M return)] 'semantic-complete-analyze-inline) | |
;; ;; (local-set-key [(M return)] 'semantic-ia-complete-symbol-menu) | |
;; ;; (local-set-key "\C-c?" 'semantic-ia-complete-symbol-menu) | |
;; ;; (local-set-key "\C-c>" 'semantic-complete-analyze-inline) | |
;; ;; (local-set-key "\C-cp" 'semantic-analyze-proto-impl-toggle) | |
;; (local-set-key [(S-mouse-2)] 'semantic-ia-fast-jump)) | |
;; (add-hook 'c-mode-common-hook 'my-cedet-hook) | |
;; (global-set-key "\C-c,s" 'semantic-speedbar-analysis) | |
(global-set-key "\C-c,c" 'toggle-camelcase-underscores) | |
;; JDEE | |
;; (add-to-list 'load-path "~/.emacs.d/jdee-2.4.1/lisp") | |
;; (load "jde") | |
(require 'jekyll-modes) | |
(remove-hook 'text-mode-hook 'turn-on-auto-fill) | |
(remove-hook 'text-mode-hook 'smart-spacing-mode) | |
(remove-hook 'text-mode-hook 'auto-detect-wrap) | |
(setq font-latex-match-reference-keywords | |
'( | |
("citeE" "[{") | |
("countlist" "[{") | |
("printlist" "[{") | |
("ndnName" "[{") | |
("name" "[{") | |
) | |
) | |
(require 'yaml-mode) | |
(add-to-list 'auto-mode-alist '("\\.yml\\'" . yaml-mode)) | |
;; (add-to-list 'magic-mode-alist | |
;; '("\\(?:<\\?xml\\s +[^>]*>\\)?\\s *<\\(?:!--\\(?:[^-]\\|-[^-]\\)*-->\\s *<\\)*\\(?:!DOCTYPE\\s +[^>]*>\\s *<\\s *\\(?:!--\\(?:[^-]\\|-[^-]\\)*-->\\s *\<\\)*\\)?[Hh][Tt][Mm][Ll]" | |
;; . html-mode)) | |
(setq web-mode-engines-alist | |
'(("django" . "\\.html\\'"))) | |
(add-hook 'web-mode-hook | |
(lambda () "" | |
(setq web-mode-markup-indent-offset 2))) | |
(add-to-list 'auto-mode-alist '("\\.html\\'" . web-mode)) | |
;; (require 'langtool) | |
;; (setq langtool-language-tool-jar "/usr/local/opt/languagetool/libexec/languagetool-commandline.jar") | |
(global-set-key "\C-x4w" 'langtool-check) | |
(global-set-key "\C-x4W" 'langtool-check-done) | |
(global-set-key "\C-x4l" 'langtool-switch-default-language) | |
(global-set-key "\C-x44" 'langtool-show-message-at-point) | |
(global-set-key "\C-x4c" 'langtool-correct-buffer) | |
(global-diff-hl-mode) | |
(setq compilation-last-buffer nil) | |
(defun compile-again (pfx) | |
"""Run the same compile as the last time. If there was no last time, or there is a prefix argument, this acts like M-x compile.""" | |
(interactive "p") | |
(if (and (eq pfx 1) | |
compilation-last-buffer) | |
(progn | |
(set-buffer compilation-last-buffer) | |
(revert-buffer t t)) | |
(call-interactively 'compile))) | |
(global-set-key "\C-cc" 'compile-again) | |
;; Disable the Built-In VC Package | |
;; (setq vc-handled-backends nil) | |
;; Magit shortcuts | |
(global-set-key (kbd "C-x g") 'magit-status) | |
(require 'magit-gerrit) | |
(setq-default magit-gerrit-ssh-creds "cawka@gerrit.named-data.net") | |
(setq-default magit-gerrit-remote "gerrit") | |
(add-hook 'TeX-mode-hook | |
(lambda () | |
(font-lock-add-keywords nil '( | |
("\\\\iffalse\\(\\(.\\|\n\\)*?\\)\\\\fi" 1 font-lock-comment-face))))) | |
(defun ales/fill-paragraph (&optional P) | |
"When called with prefix argument call `fill-paragraph'. | |
Otherwise split the current paragraph into one sentence per line." | |
(interactive "P") | |
(if (not P) | |
(save-excursion | |
(let ((fill-column 12345678)) ;; relies on dynamic binding | |
(fill-paragraph) ;; this will not work correctly if the paragraph is | |
;; longer than 12345678 characters (in which case the | |
;; file must be at least 12MB long. This is unlikely.) | |
(let ((end (save-excursion | |
(forward-paragraph 1) | |
(backward-sentence) | |
(point-marker)))) ;; remember where to stop | |
(beginning-of-line) | |
(while (progn (forward-sentence) | |
(<= (point) (marker-position end))) | |
(just-one-space) ;; leaves only one space, point is after it | |
(delete-char -1) ;; delete the space | |
(newline) ;; and insert a newline | |
(LaTeX-indent-line) ;; I only use this in combination with late, so this makes sense | |
)))) | |
;; otherwise do ordinary fill paragraph | |
(fill-paragraph P))) | |
(global-set-key (kbd "A-M-q") 'ales/fill-paragraph) | |
;; (load "preview-latex.el" nil t 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. | |
'(ecb-options-version "2.40") | |
'(package-selected-packages | |
(quote | |
(tabbar yaml-mode w3 smex nlinum magit-gh-pulls magit-gerrit langtool jenkins-watch jenkins jekyll-modes ido-vertical-mode highlight-symbol ecb diff-hl))) | |
'(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. | |
'(default ((t (:inherit nil :stipple nil :background "White" :foreground "Black" :inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant normal :weight normal :height 140 :width normal :foundry "nil" :family "Menlo")))) | |
'(linum ((t (:inherit (shadow default) :background "gray85" :height 0.7))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment