Emacs: Use with-eval-after-load instead of hooks for deferred loading
parent
e145b5d58e
commit
66009abe6c
|
@ -9,7 +9,7 @@
|
|||
To view where the bindings are set in your config files, lookup
|
||||
`mickey-minor-mode-map' over it. Example:\n
|
||||
(define-key mickey-minor-mode-map (kbd \"C-i\") 'some-function)"
|
||||
t " myckey" 'mickey-minor-mode-map)
|
||||
t " mickey" 'mickey-minor-mode-map)
|
||||
(add-hook 'minibuffer-setup-hook (lambda () (mickey-minor-mode 0)))
|
||||
|
||||
(defvar emacs-cache-folder "~/.cache/emacs/"
|
||||
|
@ -53,8 +53,7 @@ To view where the bindings are set in your config files, lookup
|
|||
|
||||
;;; BBCode
|
||||
(add-to-list 'package-selected-packages 'bbcode-mode)
|
||||
(when (require 'bbcode-mode nil t)
|
||||
(add-hook 'bbcode-mode-hook (lambda () (require 'mode-bbcode))))
|
||||
(with-eval-after-load 'bbcode-mode (require 'mode-bbcode))
|
||||
|
||||
;;; Bibtex
|
||||
(setq bibtex-entry-format '(opts-or-alts required-fields numerical-fields whitespace realign last-comma delimiters braces sort-fields))
|
||||
|
@ -65,8 +64,7 @@ To view where the bindings are set in your config files, lookup
|
|||
(add-to-list 'package-selected-packages 'bison-mode)
|
||||
|
||||
;;; C/C++
|
||||
(add-hook 'c-mode-hook (lambda () (require 'mode-cc)))
|
||||
(add-hook 'c++-mode-hook (lambda () (require 'mode-cc)))
|
||||
(with-eval-after-load 'cc-mode (require 'mode-cc))
|
||||
|
||||
;;; ChangeLog
|
||||
(defun change-log-set-indent-rules ()
|
||||
|
@ -83,8 +81,7 @@ To view where the bindings are set in your config files, lookup
|
|||
(add-to-list 'package-selected-packages 'go-rename)
|
||||
(add-to-list 'package-selected-packages 'helm-go-package)
|
||||
(add-to-list 'package-selected-packages 'company-go)
|
||||
(when (require 'go-mode nil t)
|
||||
(add-hook 'go-mode-hook (lambda () (require 'mode-go))))
|
||||
(with-eval-after-load 'go-mode (require 'mode-go))
|
||||
|
||||
;;; Graphviz dot
|
||||
;; The view command is broken but the preview command works (it displays the PNG
|
||||
|
@ -105,8 +102,7 @@ To view where the bindings are set in your config files, lookup
|
|||
|
||||
;;; Lua
|
||||
(add-to-list 'package-selected-packages 'lua-mode)
|
||||
(when (require 'lua-mode nil t)
|
||||
(add-hook 'lua-mode-hook (lambda () (require 'mode-lua))))
|
||||
(with-eval-after-load 'lua-mode (require 'mode-lua))
|
||||
|
||||
;;; Mail with Mutt support.
|
||||
(add-hook 'mail-mode-hook 'mail-text)
|
||||
|
@ -120,19 +116,18 @@ e-mail."
|
|||
(copy-file buffer-file-name mutt-backup t))
|
||||
(defun mutt-check-buffer ()
|
||||
(when (string-match "/tmp/mutt-.*" (buffer-file-name))
|
||||
(when (require 'with-editor nil t)
|
||||
;; Just like git commits.
|
||||
(with-editor-mode))
|
||||
;; Just like magit commits.
|
||||
(when (require 'with-editor nil t) (with-editor-mode))
|
||||
(add-hook 'after-save-hook 'mutt-backup-buffer nil t)))
|
||||
(add-hook 'find-file-hook 'mutt-check-buffer)
|
||||
|
||||
;;; Makefile
|
||||
(add-hook 'makefile-mode-hook (lambda () (require 'mode-makefile)))
|
||||
(with-eval-after-load 'make-mode (require 'mode-makefile))
|
||||
|
||||
;;; Markdown
|
||||
(add-to-list 'package-selected-packages 'markdown-mode)
|
||||
(when (require 'markdown-mode nil t)
|
||||
;; If we need more option, add it to a dedicated file.
|
||||
(with-eval-after-load 'markdown-mode
|
||||
;; TODO: Move config to a dedicated file.
|
||||
(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)
|
||||
|
@ -155,11 +150,10 @@ e-mail."
|
|||
;;; Mediawiki
|
||||
(add-to-list 'package-selected-packages 'mediawiki)
|
||||
(add-to-list 'auto-mode-alist '("\\.wiki\\'" . mediawiki-mode))
|
||||
(when (require 'mediawiki nil t)
|
||||
(add-hook 'mediawiki-mode-hook (lambda () (require 'mode-mediawiki))))
|
||||
(with-eval-after-load 'mediawiki (require 'mode-mediawiki))
|
||||
|
||||
;;; Org-mode
|
||||
(add-hook 'org-mode-hook (lambda () (require 'mode-org)))
|
||||
(with-eval-after-load 'org (require 'mode-org))
|
||||
|
||||
;;; Perl
|
||||
(defun perl-set-indent-rules ()
|
||||
|
@ -173,13 +167,13 @@ e-mail."
|
|||
(add-to-list 'package-selected-packages 'po-mode)
|
||||
|
||||
;;; Python
|
||||
(add-hook 'python-mode-hook (lambda () (require 'mode-python)))
|
||||
(with-eval-after-load 'python (require 'mode-python))
|
||||
|
||||
;;; Roff / Nroff
|
||||
(add-hook 'nroff-mode-hook (lambda () (require 'mode-nroff)))
|
||||
(with-eval-after-load 'nroff-mode (require 'mode-nroff))
|
||||
|
||||
;;; Shell
|
||||
(add-hook 'sh-mode-hook (lambda () (require 'mode-sh)))
|
||||
(with-eval-after-load 'sh-script (require 'mode-sh))
|
||||
;;; Arch Linux PKGBUILD
|
||||
(add-to-list 'auto-mode-alist '("PKGBUILD" . sh-mode))
|
||||
;;; rc
|
||||
|
@ -188,9 +182,7 @@ e-mail."
|
|||
(add-to-list 'package-selected-packages 'fish-mode)
|
||||
(defun fish-check-buffer ()
|
||||
(when (string-match "/tmp/tmp\..*\.fish" (buffer-file-name))
|
||||
(when (require 'with-editor nil t)
|
||||
;; Just like git commits.
|
||||
(with-editor-mode))
|
||||
(when (require 'with-editor nil t) (with-editor-mode))
|
||||
(end-of-line)))
|
||||
(add-hook 'find-file-hook 'fish-check-buffer)
|
||||
|
||||
|
@ -198,9 +190,11 @@ e-mail."
|
|||
(add-to-list 'auto-mode-alist '("\\.srt\\'" . text-mode))
|
||||
|
||||
;;; 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)))
|
||||
(with-eval-after-load 'tex-mode (require 'mode-tex))
|
||||
(with-eval-after-load 'texinfo (require 'mode-texinfo))
|
||||
;;; LaTeX is defined in the same file as TeX. To separate the loading, we add it
|
||||
;;; to the hook.
|
||||
(add-hook 'latex-mode-hook (lambda () (require 'mode-latex)))
|
||||
(add-to-list 'package-selected-packages 'latex-math-preview)
|
||||
(add-to-list 'package-selected-packages 'latex-pretty-symbols)
|
||||
(require 'latex-pretty-symbols nil t)
|
||||
|
@ -210,9 +204,7 @@ e-mail."
|
|||
;;; This works for qutebrowser, but may need changes for other browsers.
|
||||
(defun browser-check-buffer ()
|
||||
(when (string-match (concat (getenv "BROWSER") "-editor-*") (buffer-name))
|
||||
(when (require 'with-editor nil t)
|
||||
;; Just like git commits.
|
||||
(with-editor-mode))
|
||||
(when (require 'with-editor nil t) (with-editor-mode))
|
||||
(auto-fill-mode -1)))
|
||||
(add-hook 'find-file-hook 'browser-check-buffer)
|
||||
|
||||
|
@ -233,15 +225,25 @@ e-mail."
|
|||
(setq company-idle-delay nil))
|
||||
|
||||
;;; Dired
|
||||
(add-hook 'dired-mode-hook (lambda () (require 'mode-dired)))
|
||||
;;; Dired is loaded after init.el, so configure it later.
|
||||
(with-eval-after-load 'dired (require 'mode-dired))
|
||||
|
||||
;;; Eshell
|
||||
;;; Extend completion.
|
||||
(add-to-list 'package-selected-packages 'pcomplete-extension)
|
||||
;;; `eshell-first-time-mode-hook' is run too late to remove modules globally, so we do it here.
|
||||
(with-eval-after-load 'em-banner
|
||||
(setq-default eshell-modules-list (delq 'eshell-banner eshell-modules-list)))
|
||||
;;; Eshell gets initialized differently. When eshell.el first gets loaded, only
|
||||
;;; the core is defined and `eshell-load-hook' is called. For every Eshell
|
||||
;;; session, `eshell-mode' is run: it resets `eshell-mode-map', it loads
|
||||
;;; modules, runs their hooks and concludes with `eshell-first-time-mode-hook'
|
||||
;;; (for the first session only) and `eshell-mode-hook'.
|
||||
;;;
|
||||
;;; TODO: Move most features inside (with-eval-after-load 'eshell ...)
|
||||
;;; `eshell-directory-name' is part of the core.
|
||||
(with-eval-after-load 'eshell
|
||||
(setq eshell-directory-name (concat emacs-cache-folder "eshell")))
|
||||
;;; The banner is a module.
|
||||
(with-eval-after-load 'em-banner
|
||||
(setq-default eshell-modules-list (delq 'eshell-banner eshell-modules-list)))
|
||||
(add-hook 'eshell-first-time-mode-hook (lambda () (require 'mode-eshell)))
|
||||
|
||||
;;; Evil
|
||||
|
@ -252,11 +254,10 @@ e-mail."
|
|||
(add-to-list 'package-selected-packages 'evil-mc)
|
||||
(add-to-list 'package-selected-packages 'evil-mc-extras)
|
||||
(add-to-list 'package-selected-packages 'linum-relative)
|
||||
(when (require 'evil nil t)
|
||||
(require 'tool-evil))
|
||||
(when (require 'evil nil t) (require 'tool-evil))
|
||||
|
||||
;;; GUD (GDB, etc.)
|
||||
(add-hook 'gud-mode-hook (lambda () (require 'mode-gud)))
|
||||
(with-eval-after-load 'gud (require 'mode-gud))
|
||||
|
||||
;;; Helm
|
||||
(add-to-list 'package-selected-packages 'helm)
|
||||
|
@ -265,14 +266,13 @@ e-mail."
|
|||
;; (add-to-list 'package-selected-packages 'helm-pt) ; No need?
|
||||
(add-to-list 'package-selected-packages 'wgrep-helm)
|
||||
(add-to-list 'package-selected-packages 'wgrep-pt)
|
||||
(when (require 'helm-config nil t)
|
||||
(require 'tool-helm))
|
||||
(when (require 'helm-config nil t) (require 'tool-helm))
|
||||
|
||||
;;; Indentation engine fix.
|
||||
(require 'smiext "tool-smiext")
|
||||
|
||||
;;; Indent style guessing.
|
||||
(require 'dtrt-indent nil t)
|
||||
;; (add-to-list 'package-selected-packages 'dtrt-indent)
|
||||
|
||||
;;; Magit
|
||||
(add-to-list 'package-selected-packages 'magit)
|
||||
|
@ -283,6 +283,7 @@ e-mail."
|
|||
(global-set-key (kbd "C-x g") 'magit-status))
|
||||
|
||||
;;; Multiple cursors
|
||||
;;; TODO: Delete?
|
||||
;; (add-to-list 'package-selected-packages 'multiple-cursors)
|
||||
;; (add-to-list 'package-selected-packages 'phi-search)
|
||||
(when (require 'multiple-cursors nil t)
|
||||
|
@ -301,6 +302,7 @@ e-mail."
|
|||
(autoload 'pdf-compress "tool-pdf" nil t)
|
||||
|
||||
;;; Translator
|
||||
;; TODO: Find alternative package.
|
||||
(autoload 'itranslate "tool-itranslate" nil t)
|
||||
(autoload 'itranslate-lines "tool-itranslate" nil t)
|
||||
(autoload 'itranslate-region "tool-itranslate" nil t)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
;;; 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
|
||||
;;; 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'.
|
||||
|
@ -13,25 +13,17 @@
|
|||
;; (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:
|
||||
;;; 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.
|
||||
This can be useful when called from a hooked function to make
|
||||
sure it gets executed, since additions to hooks will be ignored
|
||||
while `run-mode-hooks' is running."
|
||||
(add-hook hook function)
|
||||
(funcall function))
|
||||
;; ...
|
||||
|
||||
(defun beginning-of-next-defun ()
|
||||
"Move forward to the beginning of a defun.
|
||||
|
|
|
@ -1,12 +1,9 @@
|
|||
;; BBcode
|
||||
;;; BBcode
|
||||
|
||||
; For new tags use `bbcode/make-key-binding'.
|
||||
(local-set-key (kbd "M-RET") 'bbcode/insert-tag-*)
|
||||
;;; For new tags use `bbcode/make-key-binding'.
|
||||
(define-key bbcode-mode-map (kbd "M-RET") 'bbcode/insert-tag-*)
|
||||
|
||||
(add-hook-and-eval
|
||||
'bbcode-mode-hook
|
||||
(lambda ()
|
||||
(font-lock-add-keywords nil `((,(bbcode/make-tag-regex "h") . 'font-lock-builtin-face)))
|
||||
(font-lock-add-keywords nil `((,(bbcode/make-tag-regex "\\*") . 'font-lock-string-face)))))
|
||||
(font-lock-add-keywords nil `((,(bbcode/make-tag-regex "h") . 'font-lock-builtin-face)))
|
||||
(font-lock-add-keywords nil `((,(bbcode/make-tag-regex "\\*") . 'font-lock-string-face)))
|
||||
|
||||
(provide 'mode-bbcode)
|
||||
|
|
|
@ -2,12 +2,13 @@
|
|||
|
||||
;; Should we split this into mode-c and mode-c++?
|
||||
|
||||
(local-set-key (kbd "C-c m") 'cc-main)
|
||||
(local-set-key (kbd "<f9>") 'cc-clean)
|
||||
(local-set-key (kbd "M-.") 'semantic-ia-fast-jump)
|
||||
(local-set-key (kbd "C-c C-d") 'semantic-ia-show-summary)
|
||||
(local-set-key (kbd "M-TAB") 'semantic-complete-analyze-inline)
|
||||
(local-set-key (kbd "C-c o") 'ff-find-other-file)
|
||||
(dolist (map (list c-mode-map c++-mode-map))
|
||||
(define-key map (kbd "C-c m") 'cc-main)
|
||||
(define-key map (kbd "<f9>") 'cc-clean)
|
||||
(define-key map (kbd "M-.") 'semantic-ia-fast-jump)
|
||||
(define-key map (kbd "C-c C-d") 'semantic-ia-show-summary)
|
||||
;; (define-key map (kbd "C-c o") 'ff-find-other-file)
|
||||
(define-key map (kbd "M-TAB") 'semantic-complete-analyze-inline))
|
||||
|
||||
(when (require 'company nil t)
|
||||
(local-set-key (kbd "M-TAB") (if (require 'helm-company nil t) 'helm-company 'company-complete)))
|
||||
|
@ -121,8 +122,8 @@ restored."
|
|||
;;; variables.
|
||||
(dolist (hook '(c-mode-hook c++-mode-hook))
|
||||
(when (require 'company nil t)
|
||||
(add-hook-and-eval hook 'company-mode))
|
||||
(add-hook-and-eval hook 'cc-set-compiler))
|
||||
(add-hook hook 'company-mode))
|
||||
(add-hook hook 'cc-set-compiler))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;; Skeletons
|
||||
|
|
|
@ -1,33 +1,35 @@
|
|||
;; Dired
|
||||
;;; Dired
|
||||
;;; Warning: This file is loaded unconditionally on startup.
|
||||
;;; We cannot assume that current buffer is in dired-mode.
|
||||
|
||||
(local-set-key (kbd "C-c h") 'dired-toggle-humansize)
|
||||
(local-set-key (kbd "<left>") 'dired-up-directory)
|
||||
(local-set-key (kbd "<right>") 'dired-find-file)
|
||||
(local-set-key (kbd "SPC") 'dired-mark)
|
||||
(local-set-key (kbd "<backspace>") 'dired-up-directory)
|
||||
(local-set-key (kbd "b") 'dired-up-directory)
|
||||
(let ((map dired-mode-map))
|
||||
(define-key map (kbd "C-c h") 'dired-toggle-humansize)
|
||||
(define-key map (kbd "<left>") 'dired-up-directory)
|
||||
(define-key map (kbd "<right>") 'dired-find-file)
|
||||
(define-key map (kbd "SPC") 'dired-mark)
|
||||
(define-key map (kbd "<backspace>") 'dired-up-directory)
|
||||
(define-key map (kbd "b") 'dired-up-directory))
|
||||
|
||||
(when (require 'dired+ nil t)
|
||||
(toggle-diredp-find-file-reuse-dir 1))
|
||||
|
||||
;; On a GNU system, ls has the option to sort folders first.
|
||||
;;; On a GNU system, ls has the option to sort folders first.
|
||||
(if (string-match "^gnu.*" (prin1-to-string system-type))
|
||||
(setq dired-listing-switches "--group-directories-first -lha")
|
||||
(setq dired-listing-switches "-lha"))
|
||||
|
||||
;; Switches are set before the hook is called, so we need to reload dired. The
|
||||
;; dired-internal-noselect is a lower level function, so it is faster. WARNING:
|
||||
;; Not sure if it is equivalent though.
|
||||
; (dired dired-directory dired-listing-switches)
|
||||
(dired-internal-noselect dired-directory dired-listing-switches)
|
||||
;;; Switches are set before the hook is called, so we need to reload dired. The
|
||||
;;; dired-internal-noselect is a lower level function, so it is faster. WARNING:
|
||||
;;; Not sure if it is equivalent though.
|
||||
;; (dired dired-directory dired-listing-switches)
|
||||
(defun dired-set-listing-switches ()
|
||||
(dired-internal-noselect dired-directory dired-listing-switches))
|
||||
|
||||
(setq wdired-allow-to-change-permissions t)
|
||||
|
||||
;; omit-mode needs to be started _after_ omit-files redefinition.
|
||||
;;; omit-mode needs to be started _after_ omit-files redefinition.
|
||||
(require 'dired-x)
|
||||
(setq dired-omit-files "^\\.")
|
||||
(dired-omit-mode)
|
||||
(add-hook 'dired-mode-hook 'dired-omit-mode)
|
||||
|
||||
(require 'tool-pdf) ; for `pdf-viewer'
|
||||
(setq dired-guess-shell-alist-user
|
||||
|
@ -62,4 +64,7 @@
|
|||
(setq dired-showing-humansize t))))
|
||||
(revert-buffer))
|
||||
|
||||
(dolist (fun '(dired-omit-mode dired-set-listing-switches))
|
||||
(add-hook 'dired-mode-hook fun))
|
||||
|
||||
(provide 'mode-dired)
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
;;; Eshell
|
||||
|
||||
;;; This mode has a lot of hooks.
|
||||
;;; `eshell-load-hook' is run at the very beginning; not all variables/functions will be set.
|
||||
;;; Use `eshell-first-time-mode-hook' to customize once everything is loaded.
|
||||
;;; `eshell-mode-hook' is run once per session.
|
||||
|
||||
;;; TODO: Bind "ls"? No need if we have Ctrl-e?
|
||||
;; (local-set-key "\C-l" 'eshell/ls)
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
(local-set-key (kbd "C-<f9>") (lambda () (interactive) (go-metalinter t)))
|
||||
|
||||
(when (require 'company-go nil t)
|
||||
(add-hook-and-eval 'go-mode-hook 'company-mode)
|
||||
(add-hook 'go-mode-hook 'company-mode)
|
||||
(add-to-list 'company-backends 'company-go)
|
||||
(local-set-key (kbd "M-TAB") (if (require 'helm-company nil t) 'helm-company 'company-complete)))
|
||||
|
||||
|
@ -57,11 +57,11 @@
|
|||
Note that the -cover test flag is left out since it shifts line numbers."
|
||||
(interactive)
|
||||
(setq compile-command
|
||||
(if (go-buffer-in-gopath-p)
|
||||
(if (string-match "_test.[gG][oO]$" buffer-file-name)
|
||||
"go test -v -run ."
|
||||
"go install")
|
||||
(concat "go run " (shell-quote-argument buffer-file-name)))))
|
||||
(if (go-buffer-in-gopath-p)
|
||||
(if (string-match "_test.[gG][oO]$" buffer-file-name)
|
||||
"go test -v -run ."
|
||||
"go install")
|
||||
(concat "go run " (shell-quote-argument buffer-file-name)))))
|
||||
|
||||
(defun go-buffer-in-gopath-p ()
|
||||
(if (not buffer-file-name)
|
||||
|
@ -76,7 +76,7 @@ Note that the -cover test flag is left out since it shifts line numbers."
|
|||
|
||||
(when (require 'go-guru nil t)
|
||||
(unless (executable-find "guru")
|
||||
; Requires `call-process-to-string' from `functions'."
|
||||
;; Requires `call-process-to-string' from `functions'."
|
||||
(require 'functions)
|
||||
(setq go-guru-command
|
||||
(concat (replace-regexp-in-string "\n$" "" (call-process-to-string "go" "env" "GOTOOLDIR")) "/guru"))))
|
||||
|
@ -84,15 +84,15 @@ Note that the -cover test flag is left out since it shifts line numbers."
|
|||
(defun go-turn-on-gofmt-before-save ()
|
||||
(add-hook 'before-save-hook #'gofmt-before-save nil t))
|
||||
|
||||
(add-hook-and-eval 'go-mode-hook 'go-turn-on-gofmt-before-save)
|
||||
(add-hook 'go-mode-hook 'go-turn-on-gofmt-before-save)
|
||||
|
||||
(when (require 'go-eldoc nil t)
|
||||
(add-hook-and-eval 'go-mode-hook 'go-eldoc-setup))
|
||||
(add-hook 'go-mode-hook 'go-eldoc-setup))
|
||||
|
||||
(add-hook-and-eval 'go-mode-hook 'go-set-compile-command)
|
||||
(add-hook 'go-mode-hook 'go-set-compile-command)
|
||||
|
||||
(defun godoc-setup ()
|
||||
(setq tab-width 8))
|
||||
(setq tab-width 8))
|
||||
|
||||
(add-hook 'godoc-mode-hook 'godoc-setup)
|
||||
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
;; LaTeX
|
||||
;;; LaTeX
|
||||
;;; Warning: This file is loaded from a hook.
|
||||
|
||||
;; We use the TeX setup.
|
||||
;;; We use the TeX setup.
|
||||
(require 'mode-tex)
|
||||
|
||||
;;; Since current buffer is a LaTeX one, we can use `local-set-key'.
|
||||
(local-set-key (kbd "C-c m") 'latex-article)
|
||||
(local-set-key (kbd "C-c C-a") 'latex-insert-table)
|
||||
(local-set-key (kbd "C-c C-c") 'latex-smallcaps)
|
||||
|
@ -75,10 +77,12 @@ by an {itemize} environment."
|
|||
;; Need to reset the compiler because we changed tex-command, order matters.
|
||||
(tex-set-compiler))
|
||||
|
||||
(add-hook-and-eval 'latex-mode-hook 'latex-set-compiler)
|
||||
(add-hook-and-eval 'latex-mode-hook 'turn-on-orgtbl)
|
||||
;; For some unknown reasons, `skeleton-end-hook' is set to nil in tex-mode.
|
||||
(add-hook-and-eval 'latex-mode-hook 'turn-on-skeleton-markers)
|
||||
(dolist (fun '(latex-set-compiler turn-on-orgtbl turn-on-skeleton-markers))
|
||||
;; Since this file is loaded from `latex-mode-hook', these functions will not
|
||||
;; be applied to the current buffer. We do it manually.
|
||||
(funcall fun)
|
||||
(add-hook 'latex-mode-hook fun))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Skeletons
|
||||
|
|
|
@ -5,6 +5,6 @@
|
|||
(defun lua-set-compiler ()
|
||||
(setq compile-command (concat lua-default-application " " (shell-quote-argument buffer-file-name))))
|
||||
|
||||
(add-hook-and-eval 'lua-mode-hook 'lua-set-compiler)
|
||||
(add-hook 'lua-mode-hook 'lua-set-compiler)
|
||||
|
||||
(provide 'mode-lua)
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
;; Makefile
|
||||
|
||||
(local-set-key (kbd "C-c c") 'makefile-config)
|
||||
(local-set-key (kbd "C-c d") 'makefile-doc)
|
||||
(local-set-key (kbd "C-c m") 'makefile-main)
|
||||
(local-set-key (kbd "C-c s") 'makefile-c)
|
||||
(let ((map makefile-mode-map))
|
||||
(define-key map (kbd "C-c c") 'makefile-config)
|
||||
(define-key map (kbd "C-c d") 'makefile-doc)
|
||||
(define-key map (kbd "C-c m") 'makefile-main)
|
||||
(define-key map (kbd "C-c s") 'makefile-c))
|
||||
|
||||
(define-skeleton makefile-main
|
||||
"Insert root Makefile." nil
|
||||
|
|
|
@ -5,10 +5,11 @@
|
|||
;; Besides you can try extending `url-cookie-save-interval'.
|
||||
;; Nonetheless is mode is helpfull for syntax awareness.
|
||||
|
||||
(local-set-key (kbd "C-c o") 'mediawiki-browse)
|
||||
(local-unset-key (kbd "M-g")) ; This shadows M-g M-g.
|
||||
(local-set-key (kbd "C-x C-s") 'save-buffer)
|
||||
(local-set-key (kbd "C-c M-s") 'mediawiki-save)
|
||||
(let ((map mediawiki-mode-map))
|
||||
(define-key map (kbd "C-c o") 'mediawiki-browse)
|
||||
(define-key map (kbd "M-g") nil) ; This shadows M-g M-g.
|
||||
(define-key map (kbd "C-x C-s") 'save-buffer)
|
||||
(define-key map (kbd "C-c M-s") 'mediawiki-save))
|
||||
|
||||
(setq
|
||||
mediawiki-site-alist
|
||||
|
@ -17,8 +18,8 @@
|
|||
("ArchLinux" "https://wiki.archlinux.org/" "Ambrevar" "" "Mutt")
|
||||
("WikEmacs" "https://wikemacs.org/wiki/" "Ambrevar" "" "Main Page")))
|
||||
|
||||
(add-hook-and-eval 'mediawiki-mode-hook 'visual-line-mode)
|
||||
(add-hook-and-eval 'mediawiki-mode-hook 'turn-off-auto-fill)
|
||||
(add-hook 'mediawiki-mode-hook 'visual-line-mode)
|
||||
(add-hook 'mediawiki-mode-hook 'turn-off-auto-fill)
|
||||
|
||||
(define-skeleton mediawiki-tt
|
||||
"Insert truetype text."
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
;; Nroff
|
||||
|
||||
(local-set-key (kbd "C-c C-b") 'nroff-bold)
|
||||
(local-set-key (kbd "C-c C-i") 'nroff-italic)
|
||||
(let ((map nroff-mode-map))
|
||||
(define-key map (kbd "C-c C-b") 'nroff-bold)
|
||||
(define-key map (kbd "C-c C-i") 'nroff-italic))
|
||||
|
||||
;; Skeletons
|
||||
(define-skeleton nroff-bold "Bold text." nil "\\fB" @ _ "\\fR" @)
|
||||
|
|
|
@ -1,17 +1,19 @@
|
|||
;;; Org mode
|
||||
|
||||
(local-set-key (kbd "C-c C-a") 'org-agenda)
|
||||
(define-key org-mode-map (kbd "C-c C-a") 'org-agenda)
|
||||
|
||||
;;; Move annoying babel folder.
|
||||
(setq org-babel-temporary-directory (concat emacs-cache-folder "babel"))
|
||||
;;; Disable line splitting on M-RET
|
||||
(setq org-M-RET-may-split-line '((default)))
|
||||
(setq org-insert-heading-respect-content t)
|
||||
(setq org-enforce-todo-dependencies t)
|
||||
|
||||
(setq org-deadline-warning-days 7)
|
||||
(setq org-agenda-default-appointment-duration 60)
|
||||
(setq org-agenda-columns-add-appointments-to-effort-sum t)
|
||||
(setq
|
||||
;; Move annoying babel folder.
|
||||
org-babel-temporary-directory (concat emacs-cache-folder "babel")
|
||||
;; Disable line splitting on M-RET.
|
||||
org-M-RET-may-split-line '((default))
|
||||
org-insert-heading-respect-content t
|
||||
org-enforce-todo-dependencies t
|
||||
org-deadline-warning-days 7
|
||||
org-agenda-default-appointment-duration 60
|
||||
org-agenda-columns-add-appointments-to-effort-sum t
|
||||
;; Org-mode aligns text.
|
||||
indent-tab-mode nil)
|
||||
|
||||
;;; Agendas.
|
||||
;;; If you want to add other agendas in a local file, use the following code:
|
||||
|
@ -20,15 +22,12 @@
|
|||
(add-to-list 'org-agenda-files "~/personal/todo/todo.org")
|
||||
|
||||
;;; Set PDF association in Org-mode (was Evince by default).
|
||||
(with-eval-after-load "org"
|
||||
(setq indent-tab-mode nil) ; Org-mode aligns text.
|
||||
(require 'tool-pdf)
|
||||
;; Change .pdf association directly within the alist
|
||||
(setcdr (assoc "\\.pdf\\'" org-file-apps)
|
||||
(concat pdf-viewer " " (mapconcat 'identity pdf-viewer-args " "))))
|
||||
(require 'tool-pdf)
|
||||
(setcdr (assoc "\\.pdf\\'" org-file-apps)
|
||||
(concat pdf-viewer " " (mapconcat 'identity pdf-viewer-args " ")))
|
||||
|
||||
(add-hook-and-eval 'org-mode-hook 'turn-off-linum)
|
||||
(add-hook-and-eval 'org-mode-hook 'turn-off-indent-tabs)
|
||||
(add-hook-and-eval 'org-mode-hook 'turn-off-auto-fill)
|
||||
;;; Hooks.
|
||||
(dolist (fun '(turn-off-linum turn-off-indent-tabs turn-off-auto-fill))
|
||||
(add-hook 'org-mode-hook fun))
|
||||
|
||||
(provide 'mode-org)
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
(setq compile-command
|
||||
(concat interpreter " " (shell-quote-argument buffer-file-name))))))
|
||||
|
||||
(add-hook-and-eval 'python-mode-hook 'python-set-compiler)
|
||||
(add-hook 'python-mode-hook 'python-set-compiler)
|
||||
|
||||
;; Doc lookup. Requires the python.info file to be installed. See
|
||||
;; https://bitbucket.org/jonwaltman/pydoc-info/.
|
||||
|
|
|
@ -57,9 +57,9 @@ The advantages of this function over the vanilla code are:
|
|||
(set (make-local-variable 'defun-prompt-regexp)
|
||||
(concat "^\\(function[ \t]\\|[[:alnum:]_]+[ \t]+()[ \t]+\\)")))
|
||||
|
||||
(add-hook-and-eval 'sh-mode-hook 'sh-set-indent-rules)
|
||||
(add-hook-and-eval 'sh-mode-hook 'sh-set-prompt)
|
||||
(add-hook-and-eval 'sh-mode-hook 'sh-set-compiler)
|
||||
;;; Hooks
|
||||
(dolist (fun '(sh-set-indent-rules sh-set-prompt sh-set-compiler))
|
||||
(add-hook 'sh-mode-hook fun))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
|
|
|
@ -18,10 +18,11 @@
|
|||
;; Note that -shell-escape can also be toggled with universal
|
||||
;; argument.
|
||||
|
||||
(dolist (key '("\C-c\C-f" "\C-c\C-b"))
|
||||
(local-unset-key key))
|
||||
(local-set-key (kbd "<f9>") 'tex-pdf-view)
|
||||
(local-set-key (kbd "<f10>") 'tex-compile)
|
||||
(let ((map tex-mode-map))
|
||||
(dolist (key '("\C-c\C-f" "\C-c\C-b"))
|
||||
(define-key map key nil))
|
||||
(define-key map (kbd "<f9>") 'tex-pdf-view)
|
||||
(define-key map (kbd "<f10>") 'tex-compile))
|
||||
|
||||
(defvar-local tex-masterfile nil
|
||||
"The file that should be compiled. Useful for modular documents.")
|
||||
|
@ -119,20 +120,18 @@ This does not interfere with `subword-mode'."
|
|||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; TeX setup
|
||||
|
||||
(setq-default tex-command "pdftex")
|
||||
(setq tex-command "pdftex")
|
||||
(setq-default tex-start-options "-file-line-error-style -interaction=nonstopmode -synctex=1")
|
||||
;; Use the following variable to append file local commands without erasing
|
||||
;; default options.
|
||||
(setq-default tex-start-commands nil)
|
||||
(setq-default
|
||||
tex-run-command "pdftex"
|
||||
tex-start-options "-file-line-error-style -interaction=nonstopmode -synctex=1"
|
||||
;; Use the following variable to append file local commands without erasing
|
||||
;; default options.
|
||||
tex-start-commands nil)
|
||||
|
||||
;; `tex-mode' sets `indent-tabs-mode' to nil, invoking the following
|
||||
;; argument: "TABs in verbatim environments don't do what you think." Not
|
||||
;; sure how relevant this bad comment is. We revert it.
|
||||
(add-hook-and-eval 'tex-mode-hook 'turn-on-indent-tabs)
|
||||
(add-hook-and-eval 'tex-mode-hook 'turn-on-newline-paragraph)
|
||||
(add-hook-and-eval 'tex-mode-hook 'turn-on-newline-paragraph)
|
||||
(add-hook-and-eval 'tex-mode-hook 'tex-set-compiler)
|
||||
(dolist (fun '(turn-on-indent-tabs turn-on-newline-paragraph turn-on-newline-paragraph tex-set-compiler))
|
||||
(add-hook 'tex-mode-hook fun))
|
||||
|
||||
;; Not sure how useful that is:
|
||||
;; (set (make-local-variable 'use-hard-newlines) t)
|
||||
|
|
|
@ -19,8 +19,8 @@
|
|||
(set (make-local-variable 'tex-command) "texi2pdf -b")
|
||||
(tex-set-compiler))
|
||||
|
||||
(add-hook-and-eval 'texinfo-mode-hook 'texinfo-set-compiler)
|
||||
;; For some reason, Texinfo-mode forces the fill-column to 70...
|
||||
(add-hook-and-eval 'texinfo-mode-hook 'reset-fill-column)
|
||||
(dolist (fun '(texinfo-set-compiler reset-fill-column))
|
||||
(add-hook 'texinfo-mode-hook fun))
|
||||
|
||||
(provide 'mode-texinfo)
|
||||
|
|
Loading…
Reference in New Issue