Emacs: Fix some indentation and comment style
parent
fd80913a5e
commit
38da1249c5
186
.emacs.d/init.el
186
.emacs.d/init.el
|
@ -1,7 +1,7 @@
|
|||
;; Emacs config
|
||||
;;; Emacs config
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Prerequisites
|
||||
;;; Prerequisites
|
||||
|
||||
(defvar mickey-minor-mode-map (make-keymap) "Keymap for `mickey-minor-mode'.")
|
||||
(define-minor-mode mickey-minor-mode
|
||||
|
@ -18,14 +18,14 @@ To view where the bindings are set in your config files, lookup
|
|||
(if (not (file-directory-p emacs-cache-folder))
|
||||
(make-directory emacs-cache-folder t))
|
||||
|
||||
;; Store additional config in a 'lisp' subfolder and add it to the load path so
|
||||
;; that `require' can find the files.
|
||||
;;; Store additional config in a 'lisp' subfolder and add it to the load path so
|
||||
;;; that `require' can find the files.
|
||||
(add-to-list 'load-path "~/.emacs.d/lisp")
|
||||
|
||||
;; Local plugin folder for quick install. All files in this folder will be
|
||||
;; accessible to Emacs config. This is done to separate the versioned config
|
||||
;; files from the external packages. For instance you can put package.el in
|
||||
;; there for Emacs <24.
|
||||
;;; Local plugin folder for quick install. All files in this folder will be
|
||||
;;; accessible to Emacs config. This is done to separate the versioned config
|
||||
;;; files from the external packages. For instance you can put package.el in
|
||||
;;; there for Emacs <24.
|
||||
(add-to-list 'load-path "~/.emacs.d/local")
|
||||
|
||||
(when (require 'package nil t)
|
||||
|
@ -39,43 +39,43 @@ To view where the bindings are set in your config files, lookup
|
|||
(require 'visual nil t)
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Major modes
|
||||
;;; Major modes
|
||||
|
||||
;; Assembly
|
||||
;;; Assembly
|
||||
(add-to-list 'package-selected-packages 'nasm-mode)
|
||||
|
||||
;; Asymptote
|
||||
;;; Asymptote
|
||||
(add-to-list 'load-path "/usr/share/asymptote")
|
||||
(autoload 'asy-mode "asy-mode.el" "Asymptote major mode." t)
|
||||
(autoload 'lasy-mode "asy-mode.el" "Hybrid Asymptote/Latex major mode." t)
|
||||
(autoload 'asy-insinuate-latex "asy-mode.el" "Asymptote insinuate LaTeX." t)
|
||||
(add-to-list 'auto-mode-alist '("\\.asy$" . asy-mode))
|
||||
|
||||
;; BBCode
|
||||
;;; BBCode
|
||||
(add-to-list 'package-selected-packages 'bbcode-mode)
|
||||
(load-external "\\.bbcode\\'" 'bbcode-mode)
|
||||
(add-hook 'bbcode-mode-hook (lambda () (require 'mode-bbcode)))
|
||||
|
||||
;; Bibtex
|
||||
;;; Bibtex
|
||||
(setq bibtex-entry-format '(opts-or-alts required-fields numerical-fields whitespace realign last-comma delimiters braces sort-fields))
|
||||
(setq bibtex-field-delimiters 'double-quotes)
|
||||
(add-hook 'bibtex-mode-hook (lambda () (setq indent-tabs-mode nil)))
|
||||
|
||||
;; Bison/Flex
|
||||
;;; Bison/Flex
|
||||
(load-external "\\.l\\'" 'flex-mode nil 'c-mode)
|
||||
(load-external "\\.yy?\\'" 'bison-mode nil 'c-mode)
|
||||
|
||||
;; C/C++
|
||||
;;; C/C++
|
||||
(add-hook 'c-mode-hook (lambda () (require 'mode-cc)))
|
||||
(add-hook 'c++-mode-hook (lambda () (require 'mode-cc)))
|
||||
|
||||
;; ChangeLog
|
||||
;;; ChangeLog
|
||||
(add-hook 'change-log-mode-hook (lambda () (setq tab-width 2 left-margin 2)))
|
||||
|
||||
;; GLSL
|
||||
;;; GLSL
|
||||
(load-external "\\.vert\\'\\|\\.frag\\'\\|\\.glsl\\'" 'glsl-mode nil 'c-mode)
|
||||
|
||||
;; Go
|
||||
;;; Go
|
||||
(add-to-list 'package-selected-packages 'go-mode)
|
||||
(add-to-list 'package-selected-packages 'go-eldoc)
|
||||
(add-to-list 'package-selected-packages 'go-guru)
|
||||
|
@ -85,28 +85,28 @@ To view where the bindings are set in your config files, lookup
|
|||
(load-external "\\.go\\'" 'go-mode)
|
||||
(add-hook 'go-mode-hook (lambda () (require 'mode-go)))
|
||||
|
||||
;; Graphviz dot
|
||||
;;; Graphviz dot
|
||||
(load-external "\\.dot\\'" 'graphviz-dot-mode)
|
||||
(add-hook 'graphviz-dot-mode-hook (lambda () (require 'mode-dot)))
|
||||
|
||||
;; JavaScript
|
||||
;;; JavaScript
|
||||
(add-hook 'js-mode-hook (lambda () (defvaralias 'js-indent-level 'tab-width)))
|
||||
|
||||
;; Lisp
|
||||
;; Should not use tabs.
|
||||
;;; Lisp
|
||||
;;; Should not use tabs.
|
||||
(dolist (hook '(lisp-mode-hook emacs-lisp-mode-hook))
|
||||
(add-hook hook 'turn-on-fmt-before-save)
|
||||
(add-hook hook 'turn-off-indent-tabs))
|
||||
(define-key lisp-mode-shared-map "\M-." 'find-symbol-at-point)
|
||||
;; Common LISP
|
||||
;;; Common LISP
|
||||
(setq inferior-lisp-program "clisp")
|
||||
|
||||
;; Lua
|
||||
;;; Lua
|
||||
(add-to-list 'package-selected-packages 'lua-mode)
|
||||
(load-external "\\.lua\\'" 'lua-mode nil 'sh-mode)
|
||||
(add-hook 'lua-mode-hook (lambda () (require 'mode-lua)))
|
||||
|
||||
;; Mail with Mutt support.
|
||||
;;; Mail with Mutt support.
|
||||
(add-hook 'mail-mode-hook 'mail-text)
|
||||
(add-to-list 'auto-mode-alist '("/tmp/mutt-.*" . mail-mode))
|
||||
(add-hook
|
||||
|
@ -117,66 +117,66 @@ To view where the bindings are set in your config files, lookup
|
|||
;; Just like git commits.
|
||||
(with-editor-mode))))
|
||||
|
||||
;; Makefile
|
||||
;;; Makefile
|
||||
(add-hook 'makefile-mode-hook (lambda () (require 'mode-makefile)))
|
||||
|
||||
;; Markdown
|
||||
;;; Markdown
|
||||
(add-to-list 'package-selected-packages 'markdown-mode)
|
||||
(load-external "\\.md\\'\\|\\.markdown\\'" 'markdown-mode)
|
||||
;; If we need more option, add it to a dedicated file.
|
||||
;;; If we need more option, add it to a dedicated file.
|
||||
(when (require 'markdown-mode nil t)
|
||||
(set-face-attribute 'markdown-header-face-1 nil :inherit 'info-title-1)
|
||||
(set-face-attribute 'markdown-header-face-2 nil :inherit 'info-title-2)
|
||||
(set-face-attribute 'markdown-header-face-3 nil :inherit 'info-title-3)
|
||||
(set-face-attribute 'markdown-header-face-4 nil :inherit 'info-title-4)
|
||||
(define-key markdown-mode-map "\M-'" 'markdown-blockquote-region)
|
||||
(add-hook 'markdown-mode-hook (lambda () (set (make-local-variable 'paragraph-start) "
|
||||
(set-face-attribute 'markdown-header-face-1 nil :inherit 'info-title-1)
|
||||
(set-face-attribute 'markdown-header-face-2 nil :inherit 'info-title-2)
|
||||
(set-face-attribute 'markdown-header-face-3 nil :inherit 'info-title-3)
|
||||
(set-face-attribute 'markdown-header-face-4 nil :inherit 'info-title-4)
|
||||
(define-key markdown-mode-map "\M-'" 'markdown-blockquote-region)
|
||||
(add-hook 'markdown-mode-hook (lambda () (set (make-local-variable 'paragraph-start) "
|
||||
"))))
|
||||
|
||||
;; Matlab / Octave
|
||||
;;; Matlab / Octave
|
||||
(add-to-list 'auto-mode-alist '("\\.m\\'" . octave-mode)) ; matlab
|
||||
;; Set comments to be '%' to be matlab-compatible.
|
||||
;;; Set comments to be '%' to be matlab-compatible.
|
||||
(add-hook 'octave-mode-hook (lambda () (set (make-local-variable 'comment-start) "% ")))
|
||||
|
||||
;; Maxima
|
||||
;;; Maxima
|
||||
(autoload 'maxima-mode "maxima" "Maxima mode" t)
|
||||
(autoload 'maxima "maxima" "Maxima interaction" t)
|
||||
(setq auto-mode-alist (cons '("\\.mac" . maxima-mode) auto-mode-alist))
|
||||
|
||||
;; Mediawiki
|
||||
;;; Mediawiki
|
||||
(add-to-list 'package-selected-packages 'mediawiki)
|
||||
(load-external "\\.wiki\\'" 'mediawiki 'mediawiki-mode)
|
||||
(add-hook 'mediawiki-mode-hook (lambda () (require 'mode-mediawiki)))
|
||||
|
||||
;; Org-mode
|
||||
;;; Org-mode
|
||||
(add-hook 'org-mode-hook (lambda () (require 'mode-org)))
|
||||
|
||||
;; Perl
|
||||
;;; Perl
|
||||
(add-hook
|
||||
'perl-mode-hook
|
||||
(lambda ()
|
||||
(defvaralias 'perl-indent-level 'tab-width)
|
||||
(setq compile-command (concat "perl " (shell-quote-argument buffer-file-name)))))
|
||||
|
||||
;; po
|
||||
;; No hook for this mode?
|
||||
;;; po
|
||||
;;; No hook for this mode?
|
||||
(load-external "\\.po\\'\\|\\.po\\." 'po-mode)
|
||||
(when (fboundp 'po-find-file-coding-system)
|
||||
(modify-coding-system-alist 'file "\\.po\\'\\|\\.po\\." 'po-find-file-coding-system))
|
||||
|
||||
;; Python
|
||||
;;; Python
|
||||
(add-hook 'python-mode-hook (lambda () (require 'mode-python)))
|
||||
|
||||
;; Roff / Nroff
|
||||
;;; Roff / Nroff
|
||||
(add-hook 'nroff-mode-hook (lambda () (require 'mode-nroff)))
|
||||
|
||||
;; Shell
|
||||
;;; Shell
|
||||
(add-hook 'sh-mode-hook (lambda () (require 'mode-sh)))
|
||||
;; Arch Linux PKGBUILD
|
||||
;;; Arch Linux PKGBUILD
|
||||
(add-to-list 'auto-mode-alist '("PKGBUILD" . sh-mode))
|
||||
;; rc
|
||||
;;; rc
|
||||
(add-to-list 'auto-mode-alist '("rc\\'" . sh-mode))
|
||||
;; Fish
|
||||
;;; Fish
|
||||
(add-to-list 'package-selected-packages 'fish-mode)
|
||||
(add-hook
|
||||
'find-file-hook
|
||||
|
@ -186,10 +186,10 @@ To view where the bindings are set in your config files, lookup
|
|||
;; Just like git commits.
|
||||
(with-editor-mode))))
|
||||
|
||||
;; Srt (subtitles)
|
||||
;;; Srt (subtitles)
|
||||
(add-to-list 'auto-mode-alist '("\\.srt\\'" . text-mode))
|
||||
|
||||
;; TeX / LaTeX / Texinfo
|
||||
;;; TeX / LaTeX / Texinfo
|
||||
(add-hook 'tex-mode-hook (lambda () (require 'mode-tex)))
|
||||
(add-hook 'texinfo-mode-hook (lambda () (require 'mode-texinfo)))
|
||||
(add-hook 'latex-mode-hook (lambda () (require 'mode-latex)))
|
||||
|
@ -197,9 +197,9 @@ To view where the bindings are set in your config files, lookup
|
|||
(add-to-list 'package-selected-packages 'latex-pretty-symbols)
|
||||
(require 'latex-pretty-symbols nil t)
|
||||
|
||||
;; Web forms.
|
||||
;; Remove auto-fill in web edits because wikis and forums do not like it.
|
||||
;; This works for qutebrowser, but may need changes for other browsers.
|
||||
;;; Web forms.
|
||||
;;; Remove auto-fill in web edits because wikis and forums do not like it.
|
||||
;;; This works for qutebrowser, but may need changes for other browsers.
|
||||
(add-hook
|
||||
'find-file-hook
|
||||
(lambda ()
|
||||
|
@ -209,7 +209,7 @@ To view where the bindings are set in your config files, lookup
|
|||
(with-editor-mode))
|
||||
(auto-fill-mode -1))))
|
||||
|
||||
;; XML / SGML
|
||||
;;; XML / SGML
|
||||
(add-hook
|
||||
'sgml-mode-hook
|
||||
(lambda ()
|
||||
|
@ -218,21 +218,21 @@ To view where the bindings are set in your config files, lookup
|
|||
(turn-off-auto-fill)))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Minor modes and features.
|
||||
;;; Minor modes and features.
|
||||
|
||||
;; Company
|
||||
;;; Company
|
||||
(add-to-list 'package-selected-packages 'company)
|
||||
(add-to-list 'package-selected-packages 'helm-company)
|
||||
(when (require 'company nil t)
|
||||
(setq company-idle-delay nil))
|
||||
|
||||
;; Dired
|
||||
;;; Dired
|
||||
(add-hook 'dired-mode-hook (lambda () (require 'mode-dired)))
|
||||
|
||||
;; Eshell
|
||||
;;; Eshell
|
||||
(add-hook 'eshell-load-hook (lambda () (require 'mode-eshell)))
|
||||
|
||||
;; Evil
|
||||
;;; Evil
|
||||
(add-to-list 'package-selected-packages 'evil)
|
||||
(add-to-list 'package-selected-packages 'evil-leader)
|
||||
(add-to-list 'package-selected-packages 'evil-magit)
|
||||
|
@ -242,16 +242,16 @@ To view where the bindings are set in your config files, lookup
|
|||
(when (require 'evil nil t)
|
||||
(require 'tool-evil))
|
||||
|
||||
;; God mode
|
||||
;; TODO: Evil largely replaces god-mode. Remove?
|
||||
;;; God mode
|
||||
;;; TODO: Evil largely replaces god-mode. Remove?
|
||||
;; (add-to-list 'package-selected-packages 'god-mode)
|
||||
;; (when (require 'god-mode nil t)
|
||||
;; (require 'tool-god))
|
||||
|
||||
;; GUD (GDB, etc.)
|
||||
;;; GUD (GDB, etc.)
|
||||
(add-hook 'gud-mode-hook (lambda () (require 'mode-gud)))
|
||||
|
||||
;; Helm
|
||||
;;; Helm
|
||||
(add-to-list 'package-selected-packages 'helm)
|
||||
(add-to-list 'package-selected-packages 'helm-descbinds)
|
||||
(add-to-list 'package-selected-packages 'helm-ls-git)
|
||||
|
@ -261,13 +261,13 @@ To view where the bindings are set in your config files, lookup
|
|||
(when (require 'helm-config nil t)
|
||||
(require 'tool-helm))
|
||||
|
||||
;; Indentation engine fix.
|
||||
;;; Indentation engine fix.
|
||||
(require 'smiext "tool-smiext")
|
||||
|
||||
;; Indent style guessing.
|
||||
;;; Indent style guessing.
|
||||
(require 'dtrt-indent nil t)
|
||||
|
||||
;; Magit
|
||||
;;; Magit
|
||||
(add-to-list 'package-selected-packages 'magit)
|
||||
(when (require 'magit nil t)
|
||||
(set-face-foreground 'magit-branch-remote "orange red")
|
||||
|
@ -275,7 +275,8 @@ To view where the bindings are set in your config files, lookup
|
|||
(setq magit-diff-refine-hunk 'all)
|
||||
(global-set-key (kbd "C-x g") 'magit-status))
|
||||
|
||||
;; Multiple cursors
|
||||
;;; Multiple cursors
|
||||
;;; TODO: Remove from selected-packages once evil-mc has proven itself.
|
||||
(add-to-list 'package-selected-packages 'multiple-cursors)
|
||||
(add-to-list 'package-selected-packages 'phi-search)
|
||||
(when (require 'multiple-cursors nil t)
|
||||
|
@ -290,43 +291,44 @@ To view where the bindings are set in your config files, lookup
|
|||
;; Search compatible with mc.
|
||||
(require 'phi-search nil t))
|
||||
|
||||
;; PDF
|
||||
;;; PDF
|
||||
(autoload 'pdf-view "tool-pdf" nil t)
|
||||
(autoload 'pdf-compress "tool-pdf" nil t)
|
||||
|
||||
;; Translator
|
||||
;;; Translator
|
||||
(autoload 'itranslate "tool-itranslate" nil t)
|
||||
(autoload 'itranslate-lines "tool-itranslate" nil t)
|
||||
(autoload 'itranslate-region "tool-itranslate" nil t)
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Finalization
|
||||
;;; Finalization
|
||||
|
||||
;; Don't let `customize' clutter my config.
|
||||
;; This will prompt "File exists, but cannot be read".
|
||||
;;; Don't let `customize' clutter my config.
|
||||
;;; This will prompt "File exists, but cannot be read".
|
||||
(setq custom-file "/dev/null")
|
||||
|
||||
;; We need to put it at the end to make sure it doesn't get overriden by other
|
||||
;; minor modes.
|
||||
;;; We need to put it at the end to make sure it doesn't get overriden by other
|
||||
;;; minor modes.
|
||||
(mickey-minor-mode 1)
|
||||
|
||||
;; Local hook. You can use it to set system specific variables, such as the
|
||||
;; external web browser or pdf viewer. You can also backport feature for old
|
||||
;; Emacs. For instance:
|
||||
; (setq pdf-viewer "evince")
|
||||
; (setq pdf-viewer-args nil)
|
||||
;
|
||||
; (dolist (hook '(asm-mode-hook awk-mode-hook c++-mode-hook c-mode-hook
|
||||
; emacs-lisp-mode-hook lisp-mode-hook lua-mode-hook
|
||||
; makefile-mode-hook octave-mode-hook perl-mode-hook
|
||||
; python-mode-hook scheme-mode-hook sh-mode-hook))
|
||||
; (add-hook hook (lambda () (run-hooks 'prog-mode-hook))))
|
||||
;
|
||||
; (defun comment-line... ;; From emacs 25
|
||||
;
|
||||
; (transient-mark-mode 1)
|
||||
;
|
||||
; ;; Fix slow startup when network is slow. Most visible with Helm and Magit with Emacs <25.
|
||||
; (setq tramp-ssh-controlmaster-options "-o ControlMaster=auto -o ControlPath='tramp.%%C' -o ControlPersist=no")
|
||||
;;; Local hook. You can use it to set system specific variables, such as the
|
||||
;;; external web browser or pdf viewer. You can also backport feature for old
|
||||
;;; Emacs. For instance:
|
||||
;;
|
||||
;; (setq pdf-viewer "evince")
|
||||
;; (setq pdf-viewer-args nil)
|
||||
;;
|
||||
;; (dolist (hook '(asm-mode-hook awk-mode-hook c++-mode-hook c-mode-hook
|
||||
;; emacs-lisp-mode-hook lisp-mode-hook lua-mode-hook
|
||||
;; makefile-mode-hook octave-mode-hook perl-mode-hook
|
||||
;; python-mode-hook scheme-mode-hook sh-mode-hook))
|
||||
;; (add-hook hook (lambda () (run-hooks 'prog-mode-hook))))
|
||||
;;
|
||||
;; (defun comment-line... ;; From emacs 25
|
||||
;;
|
||||
;; (transient-mark-mode 1)
|
||||
;;
|
||||
;; ;; Fix slow startup when network is slow. Most visible with Helm and Magit with Emacs <25.
|
||||
;; (setq tramp-ssh-controlmaster-options "-o ControlMaster=auto -o ControlPath='tramp.%%C' -o ControlPersist=no")
|
||||
|
||||
(load "local" t t)
|
||||
|
|
|
@ -1,25 +1,29 @@
|
|||
;; Functions
|
||||
;;; Functions
|
||||
|
||||
;; Notes on mark and region: to get a consistent behaviour regardless of Transient
|
||||
;; mode, check `(use-region-p)'. It will work as expected if
|
||||
;; transient. If not, it will always be true as soon as the mark has been set
|
||||
;; once; so you need to make sure the mark is set as you want beforehand (e.g.
|
||||
;; whole buffer, single line...). This is the behaviour of `sort-lines'.
|
||||
;;; Notes on mark and region: to get a consistent behaviour regardless of Transient
|
||||
;;; mode, check `(use-region-p)'. It will work as expected if
|
||||
;;; transient. If not, it will always be true as soon as the mark has been set
|
||||
;;; once; so you need to make sure the mark is set as you want beforehand (e.g.
|
||||
;;; whole buffer, single line...). This is the behaviour of `sort-lines'.
|
||||
;;;
|
||||
;;; The clean way to get static region boundaries and fallback on buffer boundaries:
|
||||
;;
|
||||
;; The clean way to get static region boundaries and fallback on buffer boundaries:
|
||||
; (let (start end)
|
||||
; (if (use-region-p)
|
||||
; (setq start (region-beginning) end (region-end))
|
||||
; (setq start (point-min) end (point-max)))
|
||||
;
|
||||
;; If several commands act on region and the region size/pos is susceptible to change:
|
||||
; (let ((start (set-marker (make-marker) (if (use-region-p) (region-beginning) (point-min))))
|
||||
; (end (set-marker (make-marker) (if (use-region-p) (region-end) (point-end)))))
|
||||
;
|
||||
;; For commands that only work on regions:
|
||||
; (defun count-lines-region (start end)
|
||||
; "Print number of lines and characters in the region."
|
||||
; (interactive "r")
|
||||
;; (let (start end)
|
||||
;; (if (use-region-p)
|
||||
;; (setq start (region-beginning) end (region-end))
|
||||
;; (setq start (point-min) end (point-max)))
|
||||
;;
|
||||
:;; If several commands act on region and the region size/pos is susceptible to change:
|
||||
;;
|
||||
;; (let ((start (set-marker (make-marker) (if (use-region-p) (region-beginning) (point-min))))
|
||||
;; (end (set-marker (make-marker) (if (use-region-p) (region-end) (point-end)))))
|
||||
;;
|
||||
;;
|
||||
;;; For commands that only work on regions:
|
||||
;;
|
||||
;; (defun count-lines-region (start end)
|
||||
;; "Print number of lines and characters in the region."
|
||||
;; (interactive "r")
|
||||
|
||||
(defun add-hook-and-eval (hook function)
|
||||
"Add FUNCTION to HOOK and evaluate it.
|
||||
|
@ -131,18 +135,18 @@ Work on buffer or region. Require `tabify-leading'."
|
|||
(narrow-to-region start end)
|
||||
(delete-trailing-whitespace))))
|
||||
|
||||
;; Fix forward-page. Previously, when the point was at the end of the page,
|
||||
;; going forward would skip 1 page. Changed:
|
||||
;;; Fix forward-page. Previously, when the point was at the end of the page,
|
||||
;;; going forward would skip 1 page. Changed:
|
||||
;;
|
||||
;; (if (bolp) (forward-char 1))
|
||||
;;
|
||||
;; to
|
||||
;;; to
|
||||
;;
|
||||
;; (if (string= page-delimiter "")
|
||||
;;
|
||||
;; I do not know why the (bolp) condition was used since it does not match the
|
||||
;; above comment.
|
||||
;; TODO: Fix reported to http://debbugs.gnu.org/cgi/bugreport.cgi?bug=20663.
|
||||
;;; I do not know why the (bolp) condition was used since it does not match the
|
||||
;;; above comment.
|
||||
;;; TODO: Fix reported to http://debbugs.gnu.org/cgi/bugreport.cgi?bug=20663.
|
||||
(defun forward-page (&optional count)
|
||||
"Move forward to page boundary.
|
||||
With prefix or COUNT, repeat, or go back if negative.
|
||||
|
@ -339,8 +343,8 @@ WARNING: this may slow down editing on big files."
|
|||
mode-line-misc-info
|
||||
mode-line-end-spaces)))
|
||||
|
||||
;; Almost useless compared to Helm-file M-R. However helm does not change
|
||||
;; current directory.
|
||||
;;; Almost useless compared to Helm-file M-R. However helm does not change
|
||||
;;; current directory.
|
||||
(defun rename-buffer-and-file ()
|
||||
"Renames current buffer and file it is visiting."
|
||||
(interactive)
|
||||
|
@ -405,8 +409,8 @@ If REVERSE it t, move to previous placeholder."
|
|||
"Remove trailing white space, then duplicate lines, then sort the result.
|
||||
Do not fold case with \\[universal-argument] or non-nil ARG."
|
||||
(interactive "P")
|
||||
(let ((start (set-marker (make-marker) (if (use-region-p) (region-beginning) (point-min))))
|
||||
(end (set-marker (make-marker) (if (use-region-p) (region-end) (point-end)))))
|
||||
(let ((start (set-marker (make-marker) (if (use-region-p) (region-beginning) (point-min))))
|
||||
(end (set-marker (make-marker) (if (use-region-p) (region-end) (point-end)))))
|
||||
(let ((sort-fold-case (if arg nil t)))
|
||||
(delete-trailing-whitespace start end)
|
||||
(delete-duplicate-lines start end)
|
||||
|
|
|
@ -1,101 +1,101 @@
|
|||
;; Main options
|
||||
;;; Main options
|
||||
|
||||
;; Minimal UI. Run early to hide it as soon as possible.
|
||||
;;; Minimal UI. Run early to hide it as soon as possible.
|
||||
(setq inhibit-startup-screen t)
|
||||
(if (fboundp 'tool-bar-mode) (tool-bar-mode -1))
|
||||
(menu-bar-mode -1)
|
||||
(when (fboundp 'set-scroll-bar-mode)
|
||||
(scroll-bar-mode -1))
|
||||
;;; `tool-bar-mode' and `scroll-bar-mode' might not be compiled in.
|
||||
(when (fboundp 'tool-bar-mode) (tool-bar-mode -1))
|
||||
(when (fboundp 'scroll-bar-mode) (scroll-bar-mode -1))
|
||||
|
||||
;; Remember last cursor position.
|
||||
;;; Remember last cursor position.
|
||||
(require 'saveplace)
|
||||
(setq save-place-file (concat emacs-cache-folder "saveplace"))
|
||||
(setq-default save-place-mode t)
|
||||
;; When the daemon is killed abruptly, places are not saved. Adding this hook
|
||||
;; allows to save places at a strategic moment.
|
||||
;;; When the daemon is killed abruptly, places are not saved. Adding this hook
|
||||
;;; allows to save places at a strategic moment.
|
||||
(add-hook 'before-save-hook 'save-place-kill-emacs-hook)
|
||||
|
||||
;; url-cookie
|
||||
;;; url-cookie
|
||||
(setq url-cookie-file (concat emacs-cache-folder "url.cookies"))
|
||||
|
||||
;; Bookmark file to cache folder.
|
||||
;;; Bookmark file to cache folder.
|
||||
(setq bookmark-default-file (concat emacs-cache-folder "emacs.bmk"))
|
||||
|
||||
;; Recent files.
|
||||
;;; Recent files.
|
||||
(setq recentf-save-file (concat emacs-cache-folder "recentf"))
|
||||
|
||||
;; Disable autosave features.
|
||||
;;; Disable autosave features.
|
||||
(setq auto-save-default nil)
|
||||
(setq auto-save-list-file-prefix nil)
|
||||
|
||||
;; Place backup files in specific directory.
|
||||
;;; Place backup files in specific directory.
|
||||
(setq backup-directory-alist
|
||||
`((".*" . ,(concat emacs-cache-folder "backups/"))))
|
||||
;; Other backup options.
|
||||
; (setq backup-inhibited t)
|
||||
; (setq make-backup-files t)
|
||||
; (setq version-control t)
|
||||
;;; Other backup options.
|
||||
;; (setq backup-inhibited t)
|
||||
;; (setq make-backup-files t)
|
||||
;; (setq version-control t)
|
||||
|
||||
;; Default mode
|
||||
;;; Default mode
|
||||
(setq-default major-mode 'text-mode)
|
||||
|
||||
;; Disable suspend key since it is useless on Emacs server.
|
||||
;;; Disable suspend key since it is useless on Emacs server.
|
||||
(global-unset-key (kbd "C-z"))
|
||||
(global-unset-key (kbd "C-x C-z"))
|
||||
|
||||
;; Make questions less annoying.
|
||||
;;; Make questions less annoying.
|
||||
(defalias 'yes-or-no-p 'y-or-n-p)
|
||||
|
||||
;; Allow some protected functions.
|
||||
;;; Allow some protected functions.
|
||||
(put 'upcase-region 'disabled nil)
|
||||
(put 'downcase-region 'disabled nil)
|
||||
(put 'narrow-to-page 'disabled nil)
|
||||
|
||||
;; Print column number in mode line.
|
||||
;;; Print column number in mode line.
|
||||
(column-number-mode 1)
|
||||
|
||||
;; Print buffer size in mode line.
|
||||
;;; Print buffer size in mode line.
|
||||
(size-indication-mode 1)
|
||||
|
||||
;; Kill whole line including \n.
|
||||
;;; Kill whole line including \n.
|
||||
(setq kill-whole-line t)
|
||||
|
||||
;; Alternative scrolling
|
||||
;;; Alternative scrolling
|
||||
(setq scroll-error-top-bottom t)
|
||||
|
||||
;; Narrow page navigation.
|
||||
;;; Narrow page navigation.
|
||||
(define-key mickey-minor-mode-map (kbd "C-x M-n") (lambda () (interactive) (narrow-to-page 1)))
|
||||
(define-key mickey-minor-mode-map (kbd "C-x M-p") (lambda () (interactive) (narrow-to-page -1)))
|
||||
|
||||
;; Line numbers
|
||||
;; Adding to `find-file-hook' ensures it will work for every file, regardless of
|
||||
;; the mode, but it won't work for buffers without files nor on mode change.
|
||||
;;; Line numbers
|
||||
;;; Adding to `find-file-hook' ensures it will work for every file, regardless of
|
||||
;;; the mode, but it won't work for buffers without files nor on mode change.
|
||||
(add-hook 'prog-mode-hook 'linum-mode)
|
||||
(add-hook 'text-mode-hook 'linum-mode)
|
||||
;; Emacs-nox does not display a fringe after the linum: Setting linum-format in
|
||||
;; linum-before-numbering-hook is not the right approach as it will change the
|
||||
;; type of linum-format in the middle. See linum-update-window.
|
||||
;; See http://stackoverflow.com/questions/3626632/right-align-line-numbers-with-linum-mode
|
||||
;; and http://stackoverflow.com/questions/3626632/right-align-line-numbers-with-linum-mode.
|
||||
;; The complexity is not worth the benefit.
|
||||
;;; Emacs-nox does not display a fringe after the linum: Setting linum-format in
|
||||
;;; linum-before-numbering-hook is not the right approach as it will change the
|
||||
;;; type of linum-format in the middle. See linum-update-window.
|
||||
;;; See http://stackoverflow.com/questions/3626632/right-align-line-numbers-with-linum-mode
|
||||
;;; and http://stackoverflow.com/questions/3626632/right-align-line-numbers-with-linum-mode.
|
||||
;;; The complexity is not worth the benefit.
|
||||
|
||||
;; Indentation
|
||||
;;; Indentation
|
||||
(setq-default tab-width 2)
|
||||
(defvaralias 'standard-indent 'tab-width)
|
||||
(setq-default indent-tabs-mode t)
|
||||
|
||||
;; This needs to be set globally since they are defined as local variable and
|
||||
;; Emacs does not know how to set an alias on a local variable.
|
||||
;;; This needs to be set globally since they are defined as local variable and
|
||||
;;; Emacs does not know how to set an alias on a local variable.
|
||||
(defvaralias 'c-basic-offset 'tab-width)
|
||||
(defvaralias 'sh-basic-offset 'tab-width)
|
||||
|
||||
;; Line by line scrolling
|
||||
;;; Line by line scrolling
|
||||
(setq scroll-step 1)
|
||||
|
||||
;; Autofill tweak.
|
||||
;;; Autofill tweak.
|
||||
(setq sentence-end-double-space nil)
|
||||
|
||||
;; There is no prog-mode-hook on Emacs<24.
|
||||
;;; There is no prog-mode-hook on Emacs<24.
|
||||
(require 'functions) ; for `page-number-mode'
|
||||
(add-hook 'prog-mode-hook 'page-number-mode)
|
||||
|
||||
|
@ -103,74 +103,77 @@
|
|||
(setq
|
||||
whitespace-style
|
||||
'(face empty indentation space-after-tab space-before-tab tab-mark trailing))
|
||||
;; `whitespace-report' will mistakenly always report empty lines at
|
||||
;; beginning and end of buffer as long as there is at least one empty line.
|
||||
;; `whitespace-cleanup' works properly however.
|
||||
;; DONE: Reported at http://debbugs.gnu.org/cgi/bugreport.cgi?bug=23740.
|
||||
; (setq whitespace-action '(report-on-bogus))
|
||||
;;; `whitespace-report' will mistakenly always report empty lines at
|
||||
;;; beginning and end of buffer as long as there is at least one empty line.
|
||||
;;; `whitespace-cleanup' works properly however.
|
||||
;;; DONE: Reported at http://debbugs.gnu.org/cgi/bugreport.cgi?bug=23740.
|
||||
;; (setq whitespace-action '(report-on-bogus))
|
||||
|
||||
;; WARNING: this can break some configuration files needing whitespaces at the
|
||||
;; end. This can also slow down saving on big files.
|
||||
; (require 'functions) ; for `fmt'
|
||||
; (add-hook 'before-save-hook 'fmt)
|
||||
;;; WARNING: this can break some configuration files needing whitespaces at the
|
||||
;;; end. This can also slow down saving on big files.
|
||||
;; (require 'functions) ; for `fmt'
|
||||
;; (add-hook 'before-save-hook 'fmt)
|
||||
(add-hook 'before-save-hook 'delete-trailing-whitespace)
|
||||
|
||||
;; Hippie expand.
|
||||
;;; Hippie expand.
|
||||
;; (define-key mickey-minor-mode-map (kbd "M-/") 'hippie-expand)
|
||||
|
||||
;; Abbreviation support
|
||||
;;; Abbreviation support
|
||||
(setq-default abbrev-mode t)
|
||||
|
||||
;; Set Fill Column
|
||||
;;; Set Fill Column
|
||||
(setq-default fill-column (string-to-number (getenv "MANWIDTH")))
|
||||
(add-hook 'text-mode-hook 'turn-on-auto-fill)
|
||||
|
||||
;; Enforce horizontal splitting. 140 means that the window is large enough to
|
||||
;; hold 2 other windows of 70 columns.
|
||||
;;; Enforce horizontal splitting. 140 means that the window is large enough to
|
||||
;;; hold 2 other windows of 70 columns.
|
||||
(setq split-height-threshold nil)
|
||||
(setq split-width-threshold 140)
|
||||
|
||||
;; Windmove mode: easy window switching with Shift+arrows.
|
||||
;;; Windmove mode
|
||||
;; By default, it allows easy window switching with Shift+arrows. I like to
|
||||
;; stick to the home-row, but to avoid shadowing other binding I exceptionaly use
|
||||
;; 'super' (normally reserved to the WM).
|
||||
(when (fboundp 'windmove-default-keybindings)
|
||||
(define-key mickey-minor-mode-map (kbd "M-s-h") 'windmove-left)
|
||||
(define-key mickey-minor-mode-map (kbd "M-s-j") 'windmove-down)
|
||||
(define-key mickey-minor-mode-map (kbd "M-s-k") 'windmove-up)
|
||||
(define-key mickey-minor-mode-map (kbd "M-s-l") 'windmove-right))
|
||||
|
||||
;; Make Emacs use environment browser, or w3m if BROWSER is not set.
|
||||
;;; Make Emacs use environment browser, or w3m if BROWSER is not set.
|
||||
(setq browse-url-generic-program
|
||||
(executable-find
|
||||
(let ((b (getenv "BROWSER")))
|
||||
(if b b "w3m" )))
|
||||
browse-url-browser-function 'browse-url-generic)
|
||||
|
||||
;; Default ispell dictionary. If not set, Emacs uses the current locale.
|
||||
;;; Default ispell dictionary. If not set, Emacs uses the current locale.
|
||||
(setq ispell-dictionary "english")
|
||||
|
||||
;; Long paragraphs. Useful for quick navigation with backward-paragraph and
|
||||
;; forward-paragraph.
|
||||
;;; Long paragraphs. Useful for quick navigation with backward-paragraph and
|
||||
;;; forward-paragraph.
|
||||
(setq paragraph-start "
|
||||
")
|
||||
|
||||
;; Show matching parenthesis
|
||||
;;; Show matching parenthesis
|
||||
(show-paren-mode 1)
|
||||
;; By default, there’s a small delay before showing a matching parenthesis. Set
|
||||
;; it to 0 to deactivate.
|
||||
;;; By default, there’s a small delay before showing a matching parenthesis. Set
|
||||
;;; it to 0 to deactivate.
|
||||
(setq show-paren-delay 0)
|
||||
(setq show-paren-when-point-inside-paren t)
|
||||
|
||||
;; Electric Pairs to auto-complete () [] {} "" etc. You can use it on regions.
|
||||
;;; Electric Pairs to auto-complete () [] {} "" etc. You can use it on regions.
|
||||
;; (if (>= emacs-major-version 24)
|
||||
;; (electric-pair-mode 1))
|
||||
|
||||
;; Spawn terminal shortcut: WM's binding is s+RET.
|
||||
;;; Spawn terminal shortcut: WM's binding is s+RET.
|
||||
(define-key mickey-minor-mode-map (kbd "C-x M-RET") 'spawn-terminal)
|
||||
|
||||
;; Calendar ISO display.
|
||||
;;; Calendar ISO display.
|
||||
(setq calendar-week-start-day 1)
|
||||
(setq calendar-date-style 'iso)
|
||||
|
||||
;; Compilation bindings and conveniences.
|
||||
;;; Compilation bindings and conveniences.
|
||||
(setq compilation-ask-about-save nil)
|
||||
(setq compilation-scroll-output 'first-error)
|
||||
(with-eval-after-load 'compile
|
||||
|
@ -181,14 +184,14 @@
|
|||
;; (make-variable-buffer-local 'compilation-directory)
|
||||
;; (make-variable-buffer-local 'compile-history)
|
||||
(make-variable-buffer-local 'compile-command))
|
||||
;; Don't set these bindings in mickey as we might have to override them from
|
||||
;; mode hooks.
|
||||
;;; Don't set these bindings in mickey as we might have to override them from
|
||||
;;; mode hooks.
|
||||
(global-set-key (kbd "C-<f10>") 'compile)
|
||||
(global-set-key (kbd "<f10>") (lambda () (interactive) (compile compile-command))) ; Do not use recompile since we want to change de compilation folder to the current buffer.
|
||||
(global-set-key (kbd "<f11>") 'previous-error)
|
||||
(global-set-key (kbd "<f12>") 'next-error)
|
||||
|
||||
;; Code browsing: make C-M-e jump to next function instead of the end of the current function.
|
||||
;;; Code browsing: make C-M-e jump to next function instead of the end of the current function.
|
||||
(define-key mickey-minor-mode-map (kbd "C-M-e") (lambda () (interactive) (beginning-of-defun -1)))
|
||||
|
||||
(defadvice desktop-owner (after pry-from-cold-dead-hands activate)
|
||||
|
@ -196,10 +199,10 @@
|
|||
(when (not (emacs-process-p ad-return-value))
|
||||
(setq ad-return-value nil)))
|
||||
|
||||
;; Desktop-mode
|
||||
;; Let Emacs auto-load/save sessions only when running the daemon.
|
||||
;; `server-running-p' is only useful once the daemon is started and cannot be
|
||||
;; used for initialization. We use `daemonp' instead.
|
||||
;;; Desktop-mode
|
||||
;;; Let Emacs auto-load/save sessions only when running the daemon.
|
||||
;;; `server-running-p' is only useful once the daemon is started and cannot be
|
||||
;;; used for initialization. We use `daemonp' instead.
|
||||
(when (daemonp)
|
||||
(setq history-length 250)
|
||||
(setq desktop-dirname (concat emacs-cache-folder "desktop"))
|
||||
|
@ -209,67 +212,67 @@
|
|||
;; TODO: `compile-history' should be buffer local but that does not work.
|
||||
;; http://user42.tuxfamily.org/compile-history-local/index.html
|
||||
;; http://stackoverflow.com/questions/22995203/one-compile-command-per-buffer-not-directory
|
||||
; (add-to-list 'desktop-locals-to-save 'compile-history)
|
||||
;; (add-to-list 'desktop-locals-to-save 'compile-history)
|
||||
(add-to-list 'desktop-locals-to-save 'compile-command)
|
||||
(add-to-list 'desktop-locals-to-save 'ispell-local-dictionary)
|
||||
(desktop-save-mode 1))
|
||||
|
||||
;; GMP documentation
|
||||
;;; GMP documentation
|
||||
(with-eval-after-load "info-look"
|
||||
(let ((mode-value (assoc 'c-mode (assoc 'symbol info-lookup-alist))))
|
||||
(setcar (nthcdr 3 mode-value)
|
||||
(cons '("(gmp)Function Index" nil "^ -.* " "\\>")
|
||||
(nth 3 mode-value)))))
|
||||
|
||||
;; Buffer names.
|
||||
;;; Buffer names.
|
||||
(require 'uniquify)
|
||||
(setq uniquify-buffer-name-style 'forward)
|
||||
|
||||
;; Skeleton settings
|
||||
;;; Skeleton settings
|
||||
(require 'functions)
|
||||
;; Do not expand abbrevs in skeletons.
|
||||
;;; Do not expand abbrevs in skeletons.
|
||||
(setq-default skeleton-further-elements '((abbrev-mode nil)))
|
||||
(turn-on-skeleton-markers)
|
||||
(define-key mickey-minor-mode-map (kbd "C->") 'skeleton-next-position)
|
||||
(define-key mickey-minor-mode-map (kbd "C-<") (lambda () (interactive) (skeleton-next-position t)))
|
||||
|
||||
;; Disable prompt (but leave warning) on git symlink.
|
||||
;;; Disable prompt (but leave warning) on git symlink.
|
||||
(setq vc-follow-symlinks t)
|
||||
|
||||
;; Clipboard and primary selection.
|
||||
; (setq select-enable-clipboard t)
|
||||
;;; Clipboard and primary selection.
|
||||
;; (setq select-enable-clipboard t)
|
||||
(setq select-enable-primary t)
|
||||
|
||||
;; Easy code folding toggle.
|
||||
; (add-hook 'prog-mode-hook 'hs-minor-mode)
|
||||
; (add-hook 'prog-mode-hook (lambda () (local-set-key (kbd "C-c h") 'hs-toggle-hiding)))
|
||||
;;; Easy code folding toggle.
|
||||
;; (add-hook 'prog-mode-hook 'hs-minor-mode)
|
||||
;; (add-hook 'prog-mode-hook (lambda () (local-set-key (kbd "C-c h") 'hs-toggle-hiding)))
|
||||
|
||||
;; Move mouse away.
|
||||
; (mouse-avoidance-mode 'banish)
|
||||
;;; Move mouse away.
|
||||
;; (mouse-avoidance-mode 'banish)
|
||||
|
||||
;; Display defun in mode line.
|
||||
;;; Display defun in mode line.
|
||||
(which-function-mode)
|
||||
|
||||
;; Replace maximized binding for fullscreen.
|
||||
; (define-key mickey-minor-mode-map (kbd "M-<f10>") 'toggle-frame-fullscreen)
|
||||
;;; Replace maximized binding for fullscreen.
|
||||
;; (define-key mickey-minor-mode-map (kbd "M-<f10>") 'toggle-frame-fullscreen)
|
||||
|
||||
;; Scroll zooming.
|
||||
;;; Scroll zooming.
|
||||
(define-key mickey-minor-mode-map (kbd "C-<wheel-down>") 'text-scale-decrease)
|
||||
(define-key mickey-minor-mode-map (kbd "C-<mouse-5>") 'text-scale-decrease)
|
||||
(define-key mickey-minor-mode-map (kbd "C-<wheel-up>") 'text-scale-increase)
|
||||
(define-key mickey-minor-mode-map (kbd "C-<mouse-4>") 'text-scale-increase)
|
||||
(setq text-scale-mode-step 1.1)
|
||||
|
||||
;; Sort
|
||||
;;; Sort
|
||||
(setq sort-fold-case t)
|
||||
|
||||
;; Replace not-so-useful comment-dwim binding.
|
||||
;;; Replace not-so-useful comment-dwim binding.
|
||||
(define-key mickey-minor-mode-map "\M-;" 'comment-line)
|
||||
|
||||
; In case you find eldoc too distracting.
|
||||
;;; In case you find eldoc too distracting.
|
||||
;; (global-eldoc-mode 0)
|
||||
|
||||
;; Replace `kill-buffer' binding by `kill-this-buffer'.
|
||||
;;; Replace `kill-buffer' binding by `kill-this-buffer'.
|
||||
(define-key mickey-minor-mode-map (kbd "C-x k") 'kill-this-buffer)
|
||||
|
||||
(setq ediff-window-setup-function 'ediff-setup-windows-plain
|
||||
|
|
|
@ -9,8 +9,8 @@
|
|||
(local-set-key (kbd "M-TAB") 'semantic-complete-analyze-inline)
|
||||
(local-set-key (kbd "C-c o") 'ff-find-other-file)
|
||||
|
||||
(when (fboundp 'company-mode)
|
||||
(local-set-key (kbd "M-TAB") (if (require 'company nil t) 'helm-company 'company-complete)))
|
||||
(when (require 'company nil t)
|
||||
(local-set-key (kbd "M-TAB") (if (require 'helm-company nil t) 'helm-company 'company-complete)))
|
||||
|
||||
(defvar-local cc-ldlibs "-lm -pthread"
|
||||
"Custom linker flags for C/C++ linkage.")
|
||||
|
@ -31,20 +31,20 @@ provided.\n Requires `get-closest-pathname'."
|
|||
(if (and makefile (not nomakefile))
|
||||
(setq compile-command (concat "make -k -C " (shell-quote-argument (file-name-directory makefile))))
|
||||
(setq compile-command
|
||||
(let
|
||||
((c++-p (eq major-mode 'c++-mode))
|
||||
(file (file-name-nondirectory buffer-file-name)))
|
||||
(format "%s %s -o '%s' %s %s %s"
|
||||
(if c++-p
|
||||
(or (getenv "CXX") "g++")
|
||||
(or (getenv "CC") "gcc"))
|
||||
(shell-quote-argument file)
|
||||
(shell-quote-argument (file-name-sans-extension file))
|
||||
(if c++-p
|
||||
(or (getenv "CXXFLAGS") "-Wall -Wextra -Wshadow -DDEBUG=9 -g3 -O0")
|
||||
(or (getenv "CFLAGS") "-ansi -pedantic -std=c11 -Wall -Wextra -Wshadow -DDEBUG=9 -g3 -O0"))
|
||||
(or (getenv "LDFLAGS") cc-ldflags)
|
||||
(or (getenv "LDLIBS") cc-ldlibs)))))))
|
||||
(let
|
||||
((c++-p (eq major-mode 'c++-mode))
|
||||
(file (file-name-nondirectory buffer-file-name)))
|
||||
(format "%s %s -o '%s' %s %s %s"
|
||||
(if c++-p
|
||||
(or (getenv "CXX") "g++")
|
||||
(or (getenv "CC") "gcc"))
|
||||
(shell-quote-argument file)
|
||||
(shell-quote-argument (file-name-sans-extension file))
|
||||
(if c++-p
|
||||
(or (getenv "CXXFLAGS") "-Wall -Wextra -Wshadow -DDEBUG=9 -g3 -O0")
|
||||
(or (getenv "CFLAGS") "-ansi -pedantic -std=c11 -Wall -Wextra -Wshadow -DDEBUG=9 -g3 -O0"))
|
||||
(or (getenv "LDFLAGS") cc-ldflags)
|
||||
(or (getenv "LDLIBS") cc-ldlibs)))))))
|
||||
|
||||
(defun cc-clean ()
|
||||
"Find Makefile and call the `clean' rule. If no Makefile is
|
||||
|
@ -55,11 +55,11 @@ restored."
|
|||
(when makefile
|
||||
(compile (format "make -k -f '%s' clean" makefile)))))
|
||||
|
||||
;; It is tempting to add `cc-fmt' to the hook:
|
||||
; (add-hook 'before-save-hook 'cc-fmt nil t)
|
||||
;; Unlike Go however, there is no formatting standard and thus this would break
|
||||
;; the formatting rules of every third-party C file that does not follow the
|
||||
;; same style.
|
||||
;;; It is tempting to add `cc-fmt' to the hook:
|
||||
;; (add-hook 'before-save-hook 'cc-fmt nil t)
|
||||
;;; Unlike Go however, there is no formatting standard and thus this would break
|
||||
;;; the formatting rules of every third-party C file that does not follow the
|
||||
;;; same style.
|
||||
(defun cc-fmt ()
|
||||
"Run uncrustify(1) on current buffer or region."
|
||||
(interactive)
|
||||
|
@ -78,25 +78,22 @@ restored."
|
|||
(kill-buffer formatbuf))))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Semantic options.
|
||||
;;; Options
|
||||
|
||||
;; Semanticdb folders must be set before starting semantic.
|
||||
;;; Semanticdb folders must be set before starting semantic.
|
||||
(setq semanticdb-default-save-directory (concat emacs-cache-folder "semanticdb"))
|
||||
(semantic-mode 1)
|
||||
|
||||
;; Extra semantic support
|
||||
;; Example:
|
||||
; (when (fboundp 'semantic-add-system-include)
|
||||
; (semantic-add-system-include "new/header/dir" 'c++-mode)
|
||||
; (add-to-list 'auto-mode-alist (cons qt4-base-dir 'c++-mode))
|
||||
; (add-hook
|
||||
; 'c++-mode-hook
|
||||
; (lambda ()
|
||||
; (when semantic-mode
|
||||
; (add-to-list 'semantic-lex-c-preprocessor-symbol-file "new/header/dir/config.h")))))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; C-mode
|
||||
;;; Extra semantic support
|
||||
;;; Example:
|
||||
;; (when (fboundp 'semantic-add-system-include)
|
||||
;; (semantic-add-system-include "new/header/dir" 'c++-mode)
|
||||
;; (add-to-list 'auto-mode-alist (cons qt4-base-dir 'c++-mode))
|
||||
;; (add-hook
|
||||
;; 'c++-mode-hook
|
||||
;; (lambda ()
|
||||
;; (when semantic-mode
|
||||
;; (add-to-list 'semantic-lex-c-preprocessor-symbol-file "new/header/dir/config.h")))))
|
||||
|
||||
(c-add-style
|
||||
"ambrevar"
|
||||
|
@ -118,10 +115,10 @@ restored."
|
|||
(substatement-open . 0)
|
||||
)))
|
||||
|
||||
;; Note that in Emacs 24, cc-mode calls its hooks manually in each mode init
|
||||
;; function. Since cc modes belong to prog-mode, each hook is called another
|
||||
;; time at the end of the initialization. No big deal since we only set some
|
||||
;; variables.
|
||||
;;; Note that in Emacs 24, cc-mode calls its hooks manually in each mode init
|
||||
;;; function. Since cc modes belong to prog-mode, each hook is called another
|
||||
;;; time at the end of the initialization. No big deal since we only set some
|
||||
;;; variables.
|
||||
(dolist (hook '(c-mode-hook c++-mode-hook))
|
||||
(add-hook-and-eval
|
||||
hook
|
||||
|
@ -132,11 +129,11 @@ restored."
|
|||
(add-hook-and-eval hook 'cc-set-compiler))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Skeletons
|
||||
;;; Skeletons
|
||||
|
||||
;; Note that it is possible to extend the skel syntax with
|
||||
;; `skeleton-further-elements'. For instance:
|
||||
; (setq skeleton-further-elements '((q "\"")))
|
||||
;;; Note that it is possible to extend the skel syntax with
|
||||
;;; `skeleton-further-elements'. For instance:
|
||||
; (setq skeleton-further-elements '((q "\"")))
|
||||
|
||||
(define-skeleton cc-debug
|
||||
"Insert debug macros."
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
;; Sh
|
||||
;;; Sh
|
||||
|
||||
(defvaralias 'sh-indentation 'sh-basic-offset)
|
||||
|
||||
|
@ -40,9 +40,9 @@ The advantages of this function over the vanilla code are:
|
|||
((equal (file-name-nondirectory buffer-file-name) ".profile") "sh")
|
||||
(t sh-shell-file))
|
||||
nil nil)
|
||||
;; Universal version.
|
||||
; (setq sh-shell-file (executable-find (symbol-name sh-shell)))
|
||||
;; Convenient version.
|
||||
;; Universal version:
|
||||
;; (setq sh-shell-file (executable-find (symbol-name sh-shell)))
|
||||
;; Convenient version:
|
||||
(setq sh-shell-file (concat "/bin/" (symbol-name sh-shell)))
|
||||
;; Sometimes with `git merge` it seems that the `buffer-file-name' is not a
|
||||
;; string. We safe-guard that case.
|
||||
|
@ -50,8 +50,8 @@ The advantages of this function over the vanilla code are:
|
|||
(setq compile-command (concat sh-shell-file " " (shell-quote-argument buffer-file-name)))))
|
||||
|
||||
(defun sh-set-indent-rules ()
|
||||
(setq sh-indent-for-case-label 0)
|
||||
(setq sh-indent-for-case-alt '+))
|
||||
(setq sh-indent-for-case-label 0
|
||||
sh-indent-for-case-alt '+))
|
||||
|
||||
(defun sh-set-prompt ()
|
||||
(set (make-local-variable 'defun-prompt-regexp)
|
||||
|
|
|
@ -1,21 +1,21 @@
|
|||
;; This file enforces consistency in the visual style:
|
||||
;; - doc, here-doc, comments, strings are in the same taint.
|
||||
;; - search highlight, search lazy follow the same color code.
|
||||
;; - diffs (ediff, smerge, etc.) follow the same color code.
|
||||
;;; This file enforces consistency in the visual style:
|
||||
;;; - doc, here-doc, comments, strings are in the same taint.
|
||||
;;; - search highlight, search lazy follow the same color code.
|
||||
;;; - diffs (ediff, smerge, etc.) follow the same color code.
|
||||
|
||||
;; To find the variable associated to a currently used color, place the cursor
|
||||
;; on it and call `describe-face'. Or browse the `list-faces-display'.
|
||||
;;; To find the variable associated to a currently used color, place the cursor
|
||||
;;; on it and call `describe-face'. Or browse the `list-faces-display'.
|
||||
|
||||
;; General
|
||||
;;; General
|
||||
(set-face-attribute 'default nil :foreground "white" :background "black")
|
||||
|
||||
;; Font size
|
||||
;;; Font size
|
||||
(when (fboundp 'tool-bar-mode)
|
||||
;; (set-face-attribute 'default nil :height 100)
|
||||
(add-to-list 'default-frame-alist '(font . "DejaVu Sans Mono-10")))
|
||||
|
||||
;; More readable but more space consuming; try on big screens.
|
||||
; (setq-default line-spacing 1)
|
||||
;;; More readable but more space consuming; try on big screens.
|
||||
;; (setq-default line-spacing 1)
|
||||
|
||||
(if (= emacs-major-version 23)
|
||||
(set-face-background 'modeline "white")
|
||||
|
@ -31,26 +31,26 @@
|
|||
(when (>= emacs-major-version 24)
|
||||
(set-face-attribute 'error nil :foreground "red" :weight 'bold))
|
||||
|
||||
;; Cursor type: default (box) is visible and practical.
|
||||
; (setq-default cursor-type 'hollow)
|
||||
;;; Cursor type: default (box) is visible and practical.
|
||||
;; (setq-default cursor-type 'hollow)
|
||||
(setq-default x-stretch-cursor t)
|
||||
;; Blinking cursor is on only when Emacs is not daemonized.
|
||||
;;; Blinking cursor is on only when Emacs is not daemonized.
|
||||
(blink-cursor-mode 0)
|
||||
|
||||
;; Line numbers. Graphic version has a gray bar separating text from line
|
||||
;; numbers, so we can leave the background black.
|
||||
;;; Line numbers. Graphic version has a gray bar separating text from line
|
||||
;;; numbers, so we can leave the background black.
|
||||
(if (display-graphic-p)
|
||||
(set-face-background 'shadow "black")
|
||||
(set-face-background 'shadow "#1c1c1c"))
|
||||
|
||||
;; Whitespace mode
|
||||
;;; Whitespace mode
|
||||
(add-hook
|
||||
'whitespace-load-hook
|
||||
(lambda ()
|
||||
(set-face-background 'whitespace-space-after-tab "#a9a9a9")
|
||||
(set-face-background 'whitespace-indentation "#696969")))
|
||||
|
||||
;; Programming
|
||||
;;; Programming
|
||||
(set-face-foreground 'font-lock-comment-face "#00ced1")
|
||||
(set-face-foreground 'font-lock-comment-delimiter-face (face-foreground 'font-lock-comment-face))
|
||||
(set-face-foreground 'font-lock-doc-face "#00dfff")
|
||||
|
@ -62,36 +62,36 @@
|
|||
(set-face-foreground 'font-lock-type-face (face-foreground 'default))
|
||||
(set-face-foreground 'font-lock-variable-name-face (face-foreground 'default))
|
||||
|
||||
;; Sh-mode
|
||||
;;; Sh-mode
|
||||
(add-hook
|
||||
'sh-mode-hook
|
||||
(lambda ()
|
||||
(set-face-foreground 'sh-heredoc "#00bfff")
|
||||
(set-face-bold 'sh-heredoc nil)))
|
||||
|
||||
;; Eshell
|
||||
;;; Eshell
|
||||
(add-hook
|
||||
'eshell-mode-hook
|
||||
(lambda ()
|
||||
(set-face-foreground 'eshell-prompt "#008b8b")))
|
||||
|
||||
;; Compilation mode
|
||||
;;; Compilation mode
|
||||
(add-hook
|
||||
'compilation-mode-hook
|
||||
(lambda ()
|
||||
(set-face-foreground 'compilation-column-number "cyan")
|
||||
(set-face-foreground 'compilation-line-number "cyan")))
|
||||
|
||||
;; C additional keywords.
|
||||
;;; C additional keywords.
|
||||
(dolist (mode '(c-mode c++-mode))
|
||||
(font-lock-add-keywords
|
||||
mode
|
||||
'(("\\<\\(and\\|or\\|not\\)\\>" . font-lock-keyword-face)
|
||||
;; Functions.
|
||||
("\\<\\(\\sw+\\)(" 1 'font-lock-function-name-face)
|
||||
("\\<\\(\\sw+\\)<\\sw+>(" 1 'font-lock-function-name-face))))
|
||||
(font-lock-add-keywords
|
||||
mode
|
||||
'(("\\<\\(and\\|or\\|not\\)\\>" . font-lock-keyword-face)
|
||||
;; Functions.
|
||||
("\\<\\(\\sw+\\)(" 1 'font-lock-function-name-face)
|
||||
("\\<\\(\\sw+\\)<\\sw+>(" 1 'font-lock-function-name-face))))
|
||||
|
||||
;; Ediff
|
||||
;;; Ediff
|
||||
(add-hook
|
||||
'ediff-mode-hook
|
||||
(lambda ()
|
||||
|
@ -105,7 +105,7 @@
|
|||
(set-face-attribute 'ediff-current-diff-B nil :box "white")
|
||||
(set-face-attribute 'ediff-current-diff-C nil :box "white")))
|
||||
|
||||
;; Outline mode
|
||||
;;; Outline mode
|
||||
(add-hook
|
||||
'outline-mode-hook
|
||||
(lambda ()
|
||||
|
@ -118,14 +118,15 @@
|
|||
(set-face-foreground 'outline-7 "DarkSlateGray4")
|
||||
(set-face-foreground 'outline-8 "DarkSlateBlue")))
|
||||
|
||||
;; show-paren
|
||||
(when (boundp 'show-paren-delay)
|
||||
;; (set-face-background 'show-paren-match-face (face-background 'default)) ; Disable background color.
|
||||
(set-face-background 'show-paren-match-face "#555555")
|
||||
(set-face-foreground 'show-paren-match-face "#def")
|
||||
(set-face-attribute 'show-paren-match-face nil :weight 'extra-bold))
|
||||
;;; show-paren
|
||||
(add-hook
|
||||
'show-paren-mode-hook
|
||||
;; (set-face-background 'show-paren-match-face (face-background 'default)) ; Disable background color.
|
||||
(set-face-background 'show-paren-match-face "#555555")
|
||||
(set-face-foreground 'show-paren-match-face "#def")
|
||||
(set-face-attribute 'show-paren-match-face nil :weight 'extra-bold))
|
||||
|
||||
;; Mail mode
|
||||
;;; Mail mode
|
||||
(font-lock-add-keywords
|
||||
'mail-mode
|
||||
'(
|
||||
|
@ -150,8 +151,8 @@
|
|||
;; Signature (multi-line regexes are a bit flaky).
|
||||
("^--.*\\(\n.*\\)*" . font-lock-comment-face)))
|
||||
|
||||
;; Key notes highlighting. We need to apply it to the mode hook since
|
||||
;; font-lock-add-keywords has no inheritance support.
|
||||
;;; Key notes highlighting. We need to apply it to the mode hook since
|
||||
;;; font-lock-add-keywords has no inheritance support.
|
||||
(set-face-foreground 'font-lock-warning-face "DarkOrange")
|
||||
(dolist (hook '(prog-mode-hook tex-mode-hook texinfo-mode-hook))
|
||||
(add-hook
|
||||
|
@ -164,7 +165,7 @@
|
|||
(lambda (keyword) `(,(concat "\\<\\(" keyword "\\):") 1 font-lock-warning-face prepend))
|
||||
'("FIXME\\(([^)]+)\\)?" "HACK" "OPTIMIZE\\(([^)]+)\\)?" "REVIEW\\(([^)]+)\\)?" "TODO\\(([^)]+)\\)?" "UNDONE" "UX" "WARNING" "XXX"))))))
|
||||
|
||||
;; Man pages
|
||||
;;; Man pages
|
||||
(add-hook
|
||||
'Man-mode-hook
|
||||
(lambda ()
|
||||
|
|
Loading…
Reference in New Issue