Emacs: Namespace all personal variables and functions

master
Pierre Neidhardt 2018-02-13 13:42:11 +01:00
parent 8b4b00b133
commit cb9ce6bab5
23 changed files with 230 additions and 230 deletions

View File

@ -1 +1 @@
((nil . ((fmt-inhibit-p . nil))))
((nil . ((ambrevar/fmt-inhibit-p . nil))))

View File

@ -9,22 +9,22 @@
;;; Speed up init.
;;; Temporarily reduce garbage collection during startup. Inspect `gcs-done'.
(defun reset-gc-cons-threshold ()
(defun ambrevar/reset-gc-cons-threshold ()
(setq gc-cons-threshold (car (get 'gc-cons-threshold 'standard-value))))
(setq gc-cons-threshold (* 64 1024 1024))
(add-hook 'after-init-hook 'reset-gc-cons-threshold)
(add-hook 'after-init-hook 'ambrevar/reset-gc-cons-threshold)
;;; Temporarily disable the file name handler.
(setq default-file-name-handler-alist file-name-handler-alist)
(setq file-name-handler-alist nil)
(defun reset-file-name-handler-alist ()
(defun ambrevar/reset-file-name-handler-alist ()
(setq file-name-handler-alist default-file-name-handler-alist))
(add-hook 'after-init-hook 'reset-file-name-handler-alist)
(add-hook 'after-init-hook 'ambrevar/reset-file-name-handler-alist)
(defvar emacs-cache-folder "~/.cache/emacs/"
(defvar ambrevar/emacs-cache-folder "~/.cache/emacs/"
"Cache folder is everything we do not want to track together
with the configuration files.")
(if (not (file-directory-p emacs-cache-folder))
(make-directory emacs-cache-folder t))
(if (not (file-directory-p ambrevar/emacs-cache-folder))
(make-directory ambrevar/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.
@ -38,13 +38,13 @@
(setq package-archives '(("gnu" . "https://elpa.gnu.org/packages/")))
(add-to-list 'package-archives '("melpa" . "https://melpa.milkbox.net/packages/"))
(add-to-list 'package-archives '("org" . "https://orgmode.org/elpa/") t)
(setq package-user-dir (concat emacs-cache-folder "elpa"))
(setq package-user-dir (concat ambrevar/emacs-cache-folder "elpa"))
(package-initialize))
;;; Site Lisp folder for local packages and development.
;; We need to roll it out manually since we want it first in the `load-path',
;; while `normal-top-level-add-subdirs-to-load-path' appends it to the very end.
(defun package-refresh-load-path (path)
(defun ambrevar/package-refresh-load-path (path)
"Add every non-hidden sub-folder of PATH to `load-path'."
(when (file-directory-p path)
(dolist (dir (directory-files path t "^[^\\.]"))
@ -52,7 +52,7 @@
(setq load-path (add-to-list 'load-path dir))))))
(let ((site-lisp (expand-file-name "site-lisp/" user-emacs-directory)))
(add-to-list 'load-path site-lisp)
(package-refresh-load-path site-lisp))
(ambrevar/package-refresh-load-path site-lisp))
;;; Local config. See below for an example usage.
(load "local-before" t)
@ -80,7 +80,7 @@
;;; 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 'turn-off-indent-tabs)
(add-hook 'bibtex-mode-hook 'ambrevar/turn-off-indent-tabs)
;;; Bison/Flex
;; (nconc package-selected-packages '(bison-mode))
@ -97,9 +97,9 @@
(with-eval-after-load 'cc-mode (require 'init-cc))
;;; ChangeLog
(defun change-log-set-indent-rules ()
(defun ambrevar/change-log-set-indent-rules ()
(setq tab-width 2 left-margin 2))
(add-hook 'change-log-mode-hook 'change-log-set-indent-rules)
(add-hook 'change-log-mode-hook 'ambrevar/change-log-set-indent-rules)
;;; Completion
(nconc package-selected-packages '(company helm-company))
@ -110,7 +110,7 @@
(nconc package-selected-packages '(debbugs))
(with-eval-after-load 'debbugs
(setq debbugs-gnu-all-severities t
debbugs-gnu-persistency-file (expand-file-name "debbugs" emacs-cache-folder)))
debbugs-gnu-persistency-file (expand-file-name "debbugs" ambrevar/emacs-cache-folder)))
;;; Diff
;;; REVIEW: Show permissions in ztree.
@ -215,18 +215,18 @@
additional
mark
(additional-movement normal visual motion))))
(defun init-lispy ()
(defun ambrevar/init-lispy ()
(when (require 'lispy nil t)
(set-face-foreground 'lispy-face-hint "#FF00FF")
(when (require 'lispyville nil t)
(add-hook 'lispy-mode-hook 'lispyville-mode))
(lispy-mode)))
(dolist (hook '(lisp-mode-hook emacs-lisp-mode-hook))
(add-hook hook 'turn-on-fmt-before-save)
(add-hook hook 'turn-on-complete-filename)
(add-hook hook 'turn-on-tab-width-to-8) ; Because some existing code uses tabs.
(add-hook hook 'turn-off-indent-tabs) ; Should not use tabs.
(add-hook hook 'init-lispy))
(add-hook hook 'ambrevar/turn-on-fmt-before-save)
(add-hook hook 'ambrevar/turn-on-complete-filename)
(add-hook hook 'ambrevar/turn-on-tab-width-to-8) ; Because some existing code uses tabs.
(add-hook hook 'ambrevar/turn-off-indent-tabs) ; Should not use tabs.
(add-hook hook 'ambrevar/init-lispy))
;;; Common LISP
(setq inferior-lisp-program "clisp")
@ -267,10 +267,10 @@
;;; Matlab / Octave
(add-to-list 'auto-mode-alist '("\\.m\\'" . octave-mode)) ; matlab
(defun octave-set-comment-start ()
(defun ambrevar/octave-set-comment-start ()
"Set comment character to '%' to be Matlab-compatible."
(set (make-local-variable 'comment-start) "% "))
(add-hook 'octave-mode-hook 'octave-set-comment-start)
(add-hook 'octave-mode-hook 'ambrevar/octave-set-comment-start)
;;; Maxima
(autoload 'maxima-mode "maxima" "Maxima mode" t)
@ -315,12 +315,12 @@
(pdf-tools-install t t t))
;;; Perl
(defun perl-set-indent-rules ()
(defun ambrevar/perl-set-indent-rules ()
(defvaralias 'perl-indent-level 'tab-width))
(defun perl-set-compiler ()
(defun ambrevar/perl-set-compiler ()
(setq compile-command (concat "perl " (shell-quote-argument buffer-file-name))))
(add-hook 'perl-mode-hook 'perl-set-indent-rules)
(add-hook 'perl-mode-hook 'perl-set-compiler)
(add-hook 'perl-mode-hook 'ambrevar/perl-set-indent-rules)
(add-hook 'perl-mode-hook 'ambrevar/perl-set-compiler)
;;; po
(nconc package-selected-packages '(po-mode))
@ -356,7 +356,7 @@
;;; StackExchange
(nconc package-selected-packages '(sx))
(with-eval-after-load 'sx
(setq sx-cache-directory (concat emacs-cache-folder "sx")))
(setq sx-cache-directory (concat ambrevar/emacs-cache-folder "sx")))
;;; Syntax checking
(nconc package-selected-packages '(flycheck helm-flycheck))
@ -384,14 +384,14 @@
;; `transmission' will fail to start and will not run any hook if the daemon
;; is not up yet.
;; We need to advice the function :before to guarantee it starts.
(defun transmission-start-daemon ()
(defun ambrevar/transmission-start-daemon ()
(unless (member "transmission-da"
(mapcar
(lambda (pid) (alist-get 'comm (process-attributes pid)))
(list-system-processes)))
(call-process "transmission-daemon")
(sleep-for 1)))
(advice-add 'transmission :before 'transmission-start-daemon)
(advice-add 'transmission :before 'ambrevar/transmission-start-daemon)
(setq transmission-refresh-modes '(transmission-mode transmission-files-mode transmission-info-mode transmission-peers-mode)
transmission-refresh-interval 1))
@ -401,7 +401,7 @@
(require 'google-translate-default-ui)
;; (global-set-key "\C-ct" 'google-translate-at-point)
;; (global-set-key "\C-cT" 'google-translate-query-translate)
(defun google-translate-line ()
(defun ambrevar/google-translate-line ()
"Translate current line and insert result after it, separated by ' = '."
(interactive)
(let* ((langs (google-translate-read-args nil nil))
@ -424,11 +424,11 @@
;;; 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.
(defun browser-edit ()
(defun ambrevar/browser-edit ()
(when (require 'with-editor nil t) (with-editor-mode))
(text-mode)
(auto-fill-mode -1))
(add-to-list 'auto-mode-alist `(,(concat (getenv "BROWSER") "-editor-*") . browser-edit))
(add-to-list 'auto-mode-alist `(,(concat (getenv "BROWSER") "-editor-*") . ambrevar/browser-edit))
;;; Wgrep
(nconc package-selected-packages '(wgrep-helm wgrep-pt))
@ -441,16 +441,16 @@
(when (require 'exwm nil t) (require 'init-exwm))
;;; XML / SGML
(defun sgml-setup ()
(defun ambrevar/sgml-setup ()
(setq sgml-xml-mode t)
;; (toggle-truncate-lines) ; This seems to slow down Emacs.
(turn-off-auto-fill))
(add-hook 'sgml-mode-hook 'sgml-setup)
(add-hook 'sgml-mode-hook 'ambrevar/sgml-setup)
(with-eval-after-load 'nxml-mode
(set-face-foreground 'nxml-element-local-name "gold1")
(defvaralias 'nxml-child-indent 'tab-width))
;;; Because XML is hard to read.
(add-hook 'nxml-mode-hook 'turn-on-tab-width-to-4)
(add-hook 'nxml-mode-hook 'ambrevar/turn-on-tab-width-to-4)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Finalization

View File

@ -25,13 +25,13 @@
;; (interactive "r")
;; ...
(defun call-process-to-string (program &rest args)
(defun ambrevar/call-process-to-string (program &rest args)
"Call PROGRAM with ARGS and return output."
(with-output-to-string
(with-current-buffer standard-output
(apply 'call-process program nil t nil args))))
(defun define-keys (map key def &rest bindings)
(defun ambrevar/define-keys (map key def &rest bindings)
"Like `define-key' but allow for defining several bindings at once.
`KEY' must be acceptable for `kbd'."
(while key
@ -39,7 +39,7 @@
(setq key (pop bindings)
def (pop bindings))))
(defun escape-region (&optional regex to-string)
(defun ambrevar/escape-region (&optional regex to-string)
"Escape double-quotes and backslashes.
This is useful for writing Elisp strings containing those
characters. The optional parameters let you control the replacement of REGEX for
@ -50,7 +50,7 @@ TO-STRING."
(while (re-search-forward regex (if (use-region-p) (region-end) (point-max)) t)
(replace-match to-string)))
(defun fmt ()
(defun ambrevar/fmt ()
"(Un)tabify, indent and delete trailing whitespace.
Tabify if `indent-tabs-mode' is true, otherwise use spaces.
@ -58,26 +58,26 @@ Work on buffer or region.
If `fmt-inhinit-p' is non-nil, it does nothing.
Require `tabify-leading'."
Require `ambrevar/tabify-leading'."
(interactive)
(unless fmt-inhibit-p
(unless ambrevar/fmt-inhibit-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-max)))))
(if indent-tabs-mode
(tabify-leading)
(ambrevar/tabify-leading)
(untabify start end))
(indent-region start end)
(save-restriction
(narrow-to-region start end)
(delete-trailing-whitespace)))))
(defcustom fmt-inhibit-p t
"Do not run `fmt' if non-nil.
(defcustom ambrevar/fmt-inhibit-p t
"Do not run `ambrevar/fmt' if non-nil.
As this is not friendly to foreign projects, `fmt' should be run
selectively."
:safe 'booleanp)
(defun flyspell-and-whitespace-mode ()
(defun ambrevar/flyspell-and-whitespace-mode ()
"Toggle `flyspell-mode' and `whitespace-mode'."
(interactive)
(if (derived-mode-p 'text-mode)
@ -88,7 +88,7 @@ selectively."
;;; From https://www.reddit.com/r/emacs/comments/70bn7v/what_do_you_have_emacs_show_when_it_starts_up/.
;;; Supply a random fortune cookie as the *scratch* message.
(defun fortune-scratch-message ()
(defun ambrevar/fortune-scratch-message ()
(interactive)
(let ((fortune
(when (executable-find "fortune")
@ -103,7 +103,7 @@ selectively."
(insert fortune)
fortune)))
(defun global-set-keys (key def &rest bindings)
(defun ambrevar/global-set-keys (key def &rest bindings)
"Like `global-set-key' but allow for defining several bindings at once.
`KEY' must be acceptable for `kbd'."
(while key
@ -111,7 +111,7 @@ selectively."
(setq key (pop bindings)
def (pop bindings))))
(defun insert-and-indent (text)
(defun ambrevar/insert-and-indent (text)
"Insert indented TEXT at point."
(interactive "s Text: ")
(let ((oldpoint (point)))
@ -119,7 +119,7 @@ selectively."
(indent-region oldpoint (point))
(newline-and-indent)))
(defun local-set-keys (key def &rest bindings)
(defun ambrevar/local-set-keys (key def &rest bindings)
"Like `local-set-key' but allow for defining several bindings at once.
`KEY' must be acceptable for `kbd'."
(while key
@ -127,7 +127,7 @@ selectively."
(setq key (pop bindings)
def (pop bindings))))
(defun move-border-left (arg)
(defun ambrevar/move-border-left (arg)
"Move window border in a natural manner.
If this is a window with its right edge being the edge of the
screen, enlarge the window horizontally. If this is a window with
@ -139,7 +139,7 @@ Enlarge/Shrink by ARG columns, or 5 if ARG is nil."
(move-border-left-or-right arg t)))
(global-set-key (kbd "M-(") 'move-border-left)
(defun move-border-left-or-right (arg dir-left)
(defun ambrevar/move-border-left-or-right (arg dir-left)
"Wrapper around move-border-left and move-border-right.
ARG is the number of columns to move.
If DIR-LEFT is t, then move left, otherwise move right."
@ -152,18 +152,18 @@ If DIR-LEFT is t, then move left, otherwise move right."
(shrink-window arg t)
(enlarge-window arg t))))
(defun move-border-right (arg)
(defun ambrevar/move-border-right (arg)
"See `move-border-left'."
(interactive "P")
(if (= (count-windows) 2)
(move-border-left-or-right arg nil)))
(global-set-key (kbd "M-)") 'move-border-right)
(defun reset-fill-column ()
(defun ambrevar/reset-fill-column ()
"Reset `fill-column' to its default value."
(setq fill-column (default-value 'fill-column)))
(defun shell-last-command ()
(defun ambrevar/shell-last-command ()
"Run last shell command."
(interactive)
(let ((last (car shell-command-history)))
@ -172,7 +172,7 @@ If DIR-LEFT is t, then move left, otherwise move right."
(error "Shell command history is empty"))))
(global-set-key (kbd "C-M-!") 'shell-last-command)
(defun skeleton-make-markers ()
(defun ambrevar/skeleton-make-markers ()
"Save last skeleton markers in a list.
Hook function for skeletons."
(while skeleton-markers
@ -183,12 +183,12 @@ Hook function for skeletons."
(defvar skeleton-markers nil
"Markers for locations saved in `skeleton-positions'.")
(defun skeleton-previous-position ()
(defun ambrevar/skeleton-previous-position ()
"Move to previous skeleton placeholder.
See `skeleton-next-position'."
(skeleton-next-position t))
(defun skeleton-next-position (&optional reverse)
(defun ambrevar/skeleton-next-position (&optional reverse)
"Move to next skeleton placeholder.
If REVERSE it t, move to previous placeholder."
(interactive "P")
@ -207,7 +207,7 @@ If REVERSE it t, move to previous placeholder."
(pos (goto-char pos))
(t (goto-char (car skeleton-markers)))))))
(defun sort-lines-unique (arg)
(defun ambrevar/sort-lines-unique (arg)
"Remove trailing white space, then duplicate lines, then sort the result.
Do not fold case with \\[universal-argument] or non-nil ARG."
(interactive "P")
@ -218,7 +218,7 @@ Do not fold case with \\[universal-argument] or non-nil ARG."
(delete-duplicate-lines start end)
(sort-lines nil start end))))
(defun swap-windows (&optional w1 w2)
(defun ambrevar/swap-windows (&optional w1 w2)
"If 2 windows are up, swap them.
Else if W1 is a window, swap it with current window.
If W2 is a window too, swap both."
@ -247,29 +247,29 @@ If W2 is a window too, swap both."
(select-window w1))
(global-set-key (kbd "C-x \\") 'swap-windows)
(defun swap-windows-left ()
(defun ambrevar/swap-windows-left ()
"Swap current window with the window to the left."
(interactive)
(swap-windows (window-in-direction 'left)))
(defun swap-windows-below ()
(defun ambrevar/swap-windows-below ()
"Swap current window with the window below."
(interactive)
(swap-windows (window-in-direction 'below)))
(defun swap-windows-above ()
(defun ambrevar/swap-windows-above ()
"Swap current window with the window above."
(interactive)
(swap-windows (window-in-direction 'above)))
(defun swap-windows-right ()
(defun ambrevar/swap-windows-right ()
"Swap current window with the window to the right."
(interactive)
(swap-windows (window-in-direction 'right)))
(defun switch-to-last-buffer ()
(defun ambrevar/switch-to-last-buffer ()
"Switch to last open buffer in current window."
(interactive)
(switch-to-buffer (other-buffer (current-buffer) 1)))
(defun tabify-leading ()
(defun ambrevar/tabify-leading ()
"Call `tabify' on leading spaces only.
Works on whole buffer if region is unactive."
(interactive)
@ -287,7 +287,7 @@ Works on whole buffer if region is unactive."
;;; TODO: Store window configurations in a buffer-name-indexed alist? Not
;;; sure that would ever be useful.
(defvar single-window--last-configuration nil "Last window configuration before calling `delete-other-windows'.")
(defun toggle-single-window ()
(defun ambrevar/toggle-single-window ()
"Un-maximize current window.
If multiple windows are active, save window configuration and
delete other windows. If only one window is active and a window
@ -299,7 +299,7 @@ configuration was previously save, restore that configuration."
(setq single-window--last-configuration (current-window-configuration))
(delete-other-windows)))
(defun toggle-window-dedicated ()
(defun ambrevar/toggle-window-dedicated ()
"Toggle whether the current active window is dedicated or not.
Run it in each window you want to 'freeze', i.e. prevent Emacs
from acting on it."
@ -313,7 +313,7 @@ from acting on it."
(current-buffer)))
(global-set-key (kbd "<pause>") 'toggle-window-dedicated)
(defun toggle-window-split ()
(defun ambrevar/toggle-window-split ()
"Switch between vertical and horizontal split.
It only works for frames with exactly two windows."
(interactive)
@ -341,7 +341,7 @@ It only works for frames with exactly two windows."
(if this-win-2nd (other-window 1))))))
(global-set-key (kbd "C-x C-\\") 'toggle-window-split)
(defun toggle-word-delim ()
(defun ambrevar/toggle-word-delim ()
"Make underscore part of the word syntax or not.
This does not interfere with `subword-mode'."
(interactive)
@ -355,75 +355,75 @@ This does not interfere with `subword-mode'."
;;; TODO: Move turn-on-* functions to 'hook-functions.el'?
;;; Replace useless individual comments with a single global comment.
(defun turn-on-column-number-mode ()
(defun ambrevar/turn-on-column-number-mode ()
"Unconditionally turn on `column-number-mode' for the current buffer."
(set (make-variable-buffer-local 'column-number-mode) t))
(defun turn-on-complete-filename ()
(defun ambrevar/turn-on-complete-filename ()
"Unconditionally turn on `comint-dynamic-complete-filename' for the current buffer."
(add-to-list 'completion-at-point-functions 'comint-dynamic-complete-filename t))
(defun turn-on-delete-trailing-whitespace ()
(defun ambrevar/turn-on-delete-trailing-whitespace ()
"Add the `delete-trailing-whitespace' function to `before-save-hook'.
This does not affect .csv files."
(unless (string= (file-name-extension buffer-file-name) "csv")
(add-hook 'before-save-hook 'delete-trailing-whitespace nil t)))
(defun turn-off-delete-trailing-whitespace ()
(defun ambrevar/turn-off-delete-trailing-whitespace ()
"Unconditionally remove the `delete-trailing-whitespace' function to `before-save-hook'."
(remove-hook 'before-save-hook 'delete-trailing-whitespace t))
(defun turn-on-fmt-before-save ()
(defun ambrevar/turn-on-fmt-before-save ()
"Unconditionally add the `fmt' function to `before-save-hook'."
(add-hook 'before-save-hook 'fmt nil t))
(defun turn-off-fmt-before-save ()
"Unconditionally remove the `fmt' function to `before-save-hook'."
(remove-hook 'before-save-hook 'fmt t))
(defun ambrevar/turn-off-fmt-before-save ()
"Unconditionally remove the `ambrevar/fmt' function to `before-save-hook'."
(remove-hook 'before-save-hook 'ambrevar/fmt t))
(defun turn-off-indent-tabs ()
(defun ambrevar/turn-off-indent-tabs ()
"Unconditionally turn off tab indentation."
(setq indent-tabs-mode nil))
(defun turn-on-indent-tabs ()
(defun ambrevar/turn-on-indent-tabs ()
"Unconditionally turn on tab indentation."
(setq indent-tabs-mode t))
(defun turn-off-line-number-mode ()
(defun ambrevar/turn-off-line-number-mode ()
"Unconditionally turn off `line-number-mode' fur the current buffer.."
(set (make-variable-buffer-local 'line-number-mode) nil))
(defun turn-off-linum ()
(defun ambrevar/turn-off-linum ()
"Unconditionally turn off Linum mode."
(linum-mode 0))
(defun turn-on-newline-paragraph ()
(defun ambrevar/turn-on-newline-paragraph ()
"Unconditionally make of newlines the start of a paragraph."
(set (make-local-variable 'paragraph-start) "
"))
(defun turn-off-nobreak-char-display ()
(defun ambrevar/turn-off-nobreak-char-display ()
(set (make-local-variable 'nobreak-char-display) nil))
(defun turn-on-skeleton-markers ()
(defun ambrevar/turn-on-skeleton-markers ()
"Allow skeletons to make markers to ease field navigation."
(add-hook 'skeleton-end-hook 'skeleton-make-markers))
(defun turn-on-tab-width-to-4 ()
(defun ambrevar/turn-on-tab-width-to-4 ()
"Unconditionally set tab width to 4."
(setq tab-width 4))
(defun turn-on-tab-width-to-8 ()
(defun ambrevar/turn-on-tab-width-to-8 ()
"Unconditionally set tab width to 8."
(setq tab-width 8))
(defun unfill-paragraph ()
(defun ambrevar/unfill-paragraph ()
"Paragraph at point is unwrapped on one single line."
(interactive)
(let ((fill-column (point-max)))
(fill-paragraph nil)))
(defun unfill-region ()
(defun ambrevar/unfill-region ()
"Unfill all paragraphs found in current region.
Each paragraph stand on its line."
(interactive)

View File

@ -3,11 +3,11 @@
;;; TODO: Should we split this into mode-c and mode-c++?
(dolist (map (list c-mode-map c++-mode-map))
(define-keys map "C-c m" 'cc-main
"<f5>" 'cc-clean
"M-." 'semantic-ia-fast-jump
"C-c C-d" 'semantic-ia-show-summary
"M-<tab>" 'semantic-complete-analyze-inline)
(ambrevar/define-keys map "C-c m" 'cc-main
"<f5>" 'cc-clean
"M-." 'semantic-ia-fast-jump
"C-c C-d" 'semantic-ia-show-summary
"M-<tab>" 'semantic-complete-analyze-inline)
(when (require 'company nil t)
(define-key map (kbd "M-<tab>") (if (require 'helm-company nil t) 'helm-company 'company-complete))))
;; (define-key map (kbd "C-c o") 'ff-find-other-file)
@ -103,7 +103,7 @@ restored."
;;; Options
;;; Semanticdb folders must be set before starting semantic.
(setq semanticdb-default-save-directory (concat emacs-cache-folder "semanticdb"))
(setq semanticdb-default-save-directory (concat ambrevar/emacs-cache-folder "semanticdb"))
(semantic-mode 1)
;;; Extra semantic support

View File

@ -2,13 +2,13 @@
;;; WARNING: This file is loaded unconditionally on startup.
;;; We cannot assume that current buffer is in dired-mode.
(define-keys dired-mode-map
"C-c h" 'dired-toggle-humansize
"<left>" 'dired-up-directory
"<right>" 'dired-find-file
"SPC" 'dired-mark
"<backspace>" 'dired-up-directory
"b" 'dired-up-directory)
(ambrevar/define-keys dired-mode-map
"C-c h" 'dired-toggle-humansize
"<left>" 'dired-up-directory
"<right>" 'dired-find-file
"SPC" 'dired-mark
"<backspace>" 'dired-up-directory
"b" 'dired-up-directory)
(when (require 'dired+ nil t)
(toggle-diredp-find-file-reuse-dir 1))

View File

@ -1,6 +1,6 @@
;;; Elfeed
(setq elfeed-db-directory (concat emacs-cache-folder "elfeed"))
(setq elfeed-db-directory (concat ambrevar/emacs-cache-folder "elfeed"))
(defun elfeed-play-with-mpv ()
"Play entry link with mpv."

View File

@ -4,7 +4,7 @@
;;; TODO: Change face from purple to white?
;;; TODO: Delete entry from cache? See `emms-cache-del'.
(setq emms-directory (concat emacs-cache-folder "emms"))
(setq emms-directory (concat ambrevar/emacs-cache-folder "emms"))
(emms-all)
;; TODO: emms-all causes some "require"d files to be loaded twice if called after, say, emms-browser was loaded.
(emms-history-load)

View File

@ -94,7 +94,7 @@
;;; REVIEW: `kill -#' does not work.
;;; See #29156.
(setq eshell-directory-name (concat emacs-cache-folder "eshell"))
(setq eshell-directory-name (concat ambrevar/emacs-cache-folder "eshell"))
;;; Use TRAMP to use Eshell as root.
(require 'em-tramp)
@ -120,8 +120,8 @@
(lambda nil
(let ((path (abbreviate-file-name (eshell/pwd))))
(concat
(when eshell-status-p
(propertize (or (eshell-status-display) "") 'face font-lock-comment-face))
(when ambrevar/eshell-status-p
(propertize (or (ambrevar/eshell-status-display) "") 'face font-lock-comment-face))
(format
(propertize "(%s@%s)" 'face '(:weight bold))
(propertize (user-login-name) 'face '(:foreground "cyan"))
@ -195,7 +195,7 @@
;;; Hooks
;;; `nobreak-char-display' makes some output look weird, e.g. with 'tree'.
(add-hook 'eshell-mode-hook 'turn-off-nobreak-char-display)
(add-hook 'eshell-mode-hook 'ambrevar/turn-off-nobreak-char-display)
;;; History
;;; Filter out space-beginning commands from history.
@ -208,20 +208,20 @@
(string-prefix-p " " str)))))
;;; Shared history.
(defvar eshell-history-global-ring nil
(defvar ambrevar/eshell-history-global-ring nil
"The history ring shared across Eshell sessions.")
(defun eshell-hist-use-global-history ()
(defun ambrevar/eshell-hist-use-global-history ()
"Make Eshell history shared across different sessions."
(unless eshell-history-global-ring
(unless ambrevar/eshell-history-global-ring
(when eshell-history-file-name
(eshell-read-history nil t))
(setq eshell-history-global-ring (or eshell-history-ring (make-ring eshell-history-size))))
(setq eshell-history-ring eshell-history-global-ring))
(add-hook 'eshell-mode-hook 'eshell-hist-use-global-history)
(setq ambrevar/eshell-history-global-ring (or eshell-history-ring (make-ring eshell-history-size))))
(setq eshell-history-ring ambrevar/eshell-history-global-ring))
(add-hook 'eshell-mode-hook 'ambrevar/eshell-hist-use-global-history)
;;; Spawning
(defun eshell-or-new-session (&optional arg)
(defun ambrevar/eshell-or-new-session (&optional arg)
"Create an interactive Eshell buffer.
Switch to last Eshell session if any.
Otherwise create a new one and switch to it.
@ -247,46 +247,46 @@ See `eshell' for the numeric prefix ARG."
(define-key company-active-map (kbd "M-p") 'helm-eshell-history)))
;;; Extra execution information
(defvar eshell-status-p t
(defvar ambrevar/eshell-status-p t
"If non-nil, display status before prompt.")
(defvar eshell-status--last-command-time nil)
(make-variable-buffer-local 'eshell-status--last-command-time)
(defvar eshell-status-min-duration-before-display 1
(defvar ambrevar/eshell-status--last-command-time nil)
(make-variable-buffer-local 'ambrevar/eshell-status--last-command-time)
(defvar ambrevar/eshell-status-min-duration-before-display 1
"If a command takes more time than this, display its duration.")
(defun eshell-status-display ()
(when eshell-status--last-command-time
(let ((duration (time-subtract (current-time) eshell-status--last-command-time)))
(setq eshell-status--last-command-time nil)
(when (> (time-to-seconds duration) eshell-status-min-duration-before-display)
(defun ambrevar/eshell-status-display ()
(when ambrevar/eshell-status--last-command-time
(let ((duration (time-subtract (current-time) ambrevar/eshell-status--last-command-time)))
(setq ambrevar/eshell-status--last-command-time nil)
(when (> (time-to-seconds duration) ambrevar/eshell-status-min-duration-before-display)
(format "#[STATUS] End time %s, duration %.3fs\n"
(format-time-string "%F %T" (current-time))
(time-to-seconds duration))))))
(defun eshell-status-record ()
(setq eshell-status--last-command-time (current-time)))
(defun ambrevar/eshell-status-record ()
(setq ambrevar/eshell-status--last-command-time (current-time)))
(add-hook 'eshell-pre-command-hook 'eshell-status-record)
(add-hook 'eshell-pre-command-hook 'ambrevar/eshell-status-record)
;;; Detach
(when (require 'package-eshell-detach nil t)
(defun eshell-detach-set-keys ()
(defun ambrevar/eshell-detach-set-keys ()
(define-key eshell-mode-map (kbd "C-c C-z") 'eshell-detach-stop)
(define-key eshell-mode-map (kbd "S-<return>") 'eshell-detach-send-input)
(define-key eshell-mode-map (kbd "C-<return>") 'eshell-detach-attach))
(add-hook 'eshell-mode-hook 'eshell-detach-set-keys))
(add-hook 'eshell-mode-hook 'ambrevar/eshell-detach-set-keys))
(when (string= (file-symlink-p (executable-find "man")) "mandoc")
;; Some systems like Void Linux use mandoc instead of man and do not know the
;; --nj, --nh flags.
(defun pcmpl-args-mandoc-man-function (name)
(defun ambrevar/pcmpl-args-mandoc-man-function (name)
(let ((process-environment process-environment))
;; Setting MANWIDTH to a high number makes most paragraphs fit on a single
;; line, reducing the number of false positives that result from lines
;; starting with `-' that aren't really options.
(push "MANWIDTH=10000" process-environment)
(pcmpl-args-process-file "man" "--" name)))
(setq pcmpl-args-man-function 'pcmpl-args-mandoc-man-function))
(setq pcmpl-args-man-function 'ambrevar/pcmpl-args-mandoc-man-function))
(provide 'init-eshell)

View File

@ -121,13 +121,13 @@
;; Custom Helm
(with-eval-after-load 'helm
(global-set-key (kbd "M-y") 'helm-show-kill-ring)
(define-keys helm-map
"C-\\" 'helm-toggle-resplit-and-swap-windows ; Becauste C-t is taken by evil-mc.
"M-\\" 'helm-toggle-resplit-and-swap-windows)
(ambrevar/define-keys helm-map
"C-\\" 'helm-toggle-resplit-and-swap-windows ; Becauste C-t is taken by evil-mc.
"M-\\" 'helm-toggle-resplit-and-swap-windows)
(dolist (map (list helm-find-files-map helm-read-file-map))
(define-keys map
"M-." 'helm-end-of-buffer
"M-," 'helm-beginning-of-buffer))
(ambrevar/define-keys map
"M-." 'helm-end-of-buffer
"M-," 'helm-beginning-of-buffer))
;; `helm-mark-or-exchange-rect' is not needed with Evil.
(global-set-key (kbd "C-x C-x") 'helm-all-mark-rings))

View File

@ -3,7 +3,7 @@
(setq eww-bookmarks-directory "~/personal/bookmarks"
eww-download-directory "~/temp")
(defun eww-switch-back ()
(defun ambrevar/eww-switch-back ()
"Switch to the *eww* buffer."
(interactive)
(let ((buffer (get-buffer "*eww*")))

View File

@ -54,32 +54,32 @@
(exwm-input-set-key (kbd "s-f") #'find-file)
(when (require 'functions)
(exwm-input-set-key (kbd "s-\\") #'toggle-window-split)
(exwm-input-set-key (kbd "s-H") 'swap-windows-left)
(exwm-input-set-key (kbd "s-J") 'swap-windows-below)
(exwm-input-set-key (kbd "s-K") 'swap-windows-above)
(exwm-input-set-key (kbd "s-L") 'swap-windows-right))
(exwm-input-set-key (kbd "s-\\") 'ambrevar/toggle-window-split)
(exwm-input-set-key (kbd "s-H") 'ambrevar/swap-windows-left)
(exwm-input-set-key (kbd "s-J") 'ambrevar/swap-windows-below)
(exwm-input-set-key (kbd "s-K") 'ambrevar/swap-windows-above)
(exwm-input-set-key (kbd "s-L") 'ambrevar/swap-windows-right))
;; The following can only apply to EXWM buffers, else it could have unexpected effects.
(push ?\s- exwm-input-prefix-keys)
(define-key exwm-mode-map (kbd "s-SPC") #'exwm-floating-toggle-floating)
(exwm-input-set-key (kbd "s-i") #'follow-delete-other-windows-and-split)
(exwm-input-set-key (kbd "s-o") #'toggle-single-window)
(exwm-input-set-key (kbd "s-o") #'ambrevar/toggle-single-window)
(exwm-input-set-key (kbd "s-O") #'exwm-layout-toggle-fullscreen)
(with-eval-after-load 'helm
;; Need `with-eval-after-load' here since 'helm-map is not defined in 'helm-config.
(define-keys helm-map
"s-\\" 'helm-toggle-resplit-and-swap-windows)
(ambrevar/define-keys helm-map
"s-\\" 'helm-toggle-resplit-and-swap-windows)
(exwm-input-set-key (kbd "s-c") #'helm-resume)
(exwm-input-set-key (kbd "s-b") #'helm-mini)
(exwm-input-set-key (kbd "s-f") #'helm-find-files)
(exwm-input-set-key (kbd "s-F") #'helm-locate)
(when (fboundp 'helm-locate-meta)
(exwm-input-set-key (kbd "s-F") #'helm-locate-meta))
(exwm-input-set-key (kbd "s-g") #'helm-grep-git-or-ag)
(exwm-input-set-key (kbd "s-G") #'helm-grep-git-all-or-ag))
(exwm-input-set-key (kbd "s-g") 'ambrevar/helm-grep-git-or-ag)
(exwm-input-set-key (kbd "s-G") 'ambrevar/helm-grep-git-all-or-ag))
(require 'functions)
(exwm-input-set-key (kbd "s-<tab>") #'switch-to-last-buffer)
@ -88,9 +88,9 @@
(exwm-input-set-key (kbd "C-6") #'evil-switch-to-windows-last-buffer))
;;; Emacs mode shortcuts.
(exwm-input-set-key (kbd "s-t") #'org-switch-agenda-file)
(exwm-input-set-key (kbd "s-T") #'org-switch-agenda-file-other-window)
(exwm-input-set-key (kbd "s-<return>") #'eshell-or-new-session)
(exwm-input-set-key (kbd "s-t") #'ambrevar/org-switch-agenda-file)
(exwm-input-set-key (kbd "s-T") #'ambrevar/org-switch-agenda-file-other-window)
(exwm-input-set-key (kbd "s-<return>") #'ambrevar/eshell-or-new-session)
(when (fboundp 'magit-status)
(exwm-input-set-key (kbd "s-v") #'magit-status))
(when (fboundp 'emms-all)
@ -103,8 +103,8 @@
(exwm-input-set-key (kbd "s-p") #'helm-pass))
(when (delq nil (mapcar (lambda (path) (string-match "/mu4e/\\|/mu4e$" path)) load-path))
(exwm-input-set-key (kbd "s-m") #'mu4e-headers))
(exwm-input-set-key (kbd "s-n") #'elfeed-switch-back) ; "n" for "news"
(exwm-input-set-key (kbd "s-e") #'eww-switch-back)
(exwm-input-set-key (kbd "s-n") #'ambrevar/elfeed-switch-back) ; "n" for "news"
(exwm-input-set-key (kbd "s-e") #'ambrevar/eww-switch-back)
(exwm-input-set-key (kbd "s-E") #'eww)
@ -127,8 +127,8 @@
helm-source-bookmarks
helm-source-bookmark-set
helm-source-buffer-not-found))
(define-keys helm-exwm-map "M-d" 'helm-buffer-run-kill-persistent)
(define-keys helm-exwm-map "S-<return>" 'helm-buffer-switch-other-window)
(ambrevar/define-keys helm-exwm-map "M-d" 'helm-buffer-run-kill-persistent)
(ambrevar/define-keys helm-exwm-map "S-<return>" 'helm-buffer-switch-other-window)
;; Launcher
(exwm-input-set-key (kbd "s-r") 'helm-run-external-command)
;; Web browser

View File

@ -4,7 +4,7 @@
;;; Reported at https://github.com/dominikh/go-mode.el/issues/191.
(use-local-map go-mode-map)
(local-set-keys
(ambrevar/local-set-keys
"C-c m" 'go-main
"C-c D" 'godoc
"C-c d" 'godoc-at-point
@ -87,12 +87,12 @@ Note that the -cover test flag is left out since it shifts line numbers."
;; 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"))))
(concat (replace-regexp-in-string "\n$" "" (ambrevar/call-process-to-string "go" "env" "GOTOOLDIR")) "/guru"))))
(defun go-turn-on-gofmt-before-save ()
(defun ambrevar/go-turn-on-gofmt-before-save ()
(add-hook 'before-save-hook #'gofmt-before-save nil t))
(add-hook 'go-mode-hook 'go-turn-on-gofmt-before-save)
(add-hook 'go-mode-hook 'ambrevar/go-turn-on-gofmt-before-save)
(when (require 'go-eldoc nil t)
(add-hook 'go-mode-hook 'go-eldoc-setup))

View File

@ -68,7 +68,7 @@
helm-window-show-buffers-function 'helm-window-mosaic-fn
helm-window-prefer-horizontal-split t)
(defun helm-split-window-combined-fn (window)
(defun ambrevar/helm-split-window-combined-fn (window)
"Helm window splitting that combined most standard features.
- With C-u, split inside. With C-u C-u, use same window.
@ -98,25 +98,25 @@
(if (> (window-pixel-width) (window-pixel-height))
'right
'below)))))
(setq helm-split-window-preferred-function 'helm-split-window-combined-fn)
(setq helm-split-window-preferred-function 'ambrevar/helm-split-window-combined-fn)
;;; From https://github.com/emacs-helm/helm/issues/362.
;;; This is not perfect with evil mode as the cursor type is not right in the
;;; header line and the evil cursor remains in the minibuffer.
;;; https://emacs.stackexchange.com/questions/17058/change-cursor-type-in-helm-header-line#17097
(setq helm-echo-input-in-header-line t)
(defun helm-hide-minibuffer-maybe ()
(defun ambrevar/helm-hide-minibuffer-maybe ()
(when (with-helm-buffer helm-echo-input-in-header-line)
(let ((ov (make-overlay (point-min) (point-max) nil nil t)))
(overlay-put ov 'window (selected-window))
(overlay-put ov 'face (let ((bg-color (face-background 'default nil)))
`(:background ,bg-color :foreground ,bg-color)))
(setq-local cursor-type nil))))
(add-hook 'helm-minibuffer-set-up-hook 'helm-hide-minibuffer-maybe)
(add-hook 'helm-minibuffer-set-up-hook 'ambrevar/helm-hide-minibuffer-maybe)
;;; Add bindings to `helm-apropos`. TODO: Does not work most of the times.
;;; https://github.com/emacs-helm/helm/issues/1140
(defun helm-def-source--emacs-commands (&optional default)
(defun ambrevar/helm-def-source--emacs-commands (&optional default)
(helm-build-in-buffer-source "Commands"
:init `(lambda ()
(helm-apropos-init 'commandp ,default))
@ -139,12 +139,12 @@
helm-source-buffer-not-found))
;;; Eshell
(defun helm/eshell-set-keys ()
(defun ambrevar/helm/eshell-set-keys ()
(define-key eshell-mode-map [remap eshell-pcomplete] 'helm-esh-pcomplete)
(define-key eshell-mode-map (kbd "M-p") 'helm-eshell-history)
(define-key eshell-mode-map (kbd "M-s") nil) ; Useless when we have 'helm-eshell-history.
(define-key eshell-mode-map (kbd "M-s f") 'helm-eshell-prompts-all))
(add-hook 'eshell-mode-hook 'helm/eshell-set-keys)
(add-hook 'eshell-mode-hook 'ambrevar/helm/eshell-set-keys)
;;; TODO: Use helm-ff history in helm file completion.
;;; https://github.com/emacs-helm/helm/issues/1118
@ -153,23 +153,23 @@
;;; Do not exclude any files from 'git grep'.
(setq helm-grep-git-grep-command "git --no-pager grep -n%cH --color=always --full-name -e %p -- %f")
(defun helm-grep-git-or-ag (arg)
(defun ambrevar/helm-grep-git-or-ag (arg)
"Run `helm-grep-do-git-grep' if possible; fallback to `helm-do-grep-ag' otherwise.
Requires `call-process-to-string' from `functions'."
(interactive "P")
(require 'vc)
(require 'functions)
(if (and (vc-find-root default-directory ".git")
(or arg (split-string (call-process-to-string "git" "ls-files" "-z") "\0" t)))
(or arg (split-string (ambrevar/call-process-to-string "git" "ls-files" "-z") "\0" t)))
(helm-grep-do-git-grep arg)
(helm-do-grep-ag nil)))
(defun helm-grep-git-all-or-ag ()
(defun ambrevar/helm-grep-git-all-or-ag ()
"Run `helm-grep-do-git-grep' over all git files."
(interactive)
(helm-grep-do-git-grep t))
(defun helm-mark-or-exchange-rect ()
(defun ambrevar/helm-mark-or-exchange-rect ()
"Run `helm-all-mark-rings-before-mark-point' or `rectangle-exchange-point-and-mark' if in rectangle-mark-mode."
(interactive)
(if rectangle-mark-mode
@ -183,15 +183,15 @@ Requires `call-process-to-string' from `functions'."
;; (global-set-key [remap dabbrev-expand] 'helm-dabbrev)
(global-set-key [remap yank-pop] 'helm-show-kill-ring)
;;; Do not remap 'exchange-point-and-mark, Evil needs it in visual mode.
(global-set-key (kbd "C-x C-x") 'helm-mark-or-exchange-rect)
(global-set-key (kbd "C-x C-x") 'ambrevar/helm-mark-or-exchange-rect)
(global-set-key [remap apropos-command] 'helm-apropos)
(global-set-key [remap query-replace-regexp] 'helm-regexp)
(unless (boundp 'completion-in-region-function)
(define-key lisp-interaction-mode-map [remap completion-at-point] 'helm-lisp-completion-at-point)
(define-key emacs-lisp-mode-map [remap completion-at-point] 'helm-lisp-completion-at-point))
(global-set-keys
"C-x M-g" 'helm-grep-git-or-ag
(ambrevar/global-set-keys
"C-x M-g" 'ambrevar/helm-grep-git-or-ag
"C-x M-G" 'helm-do-grep-ag)
;;; Use the M-s prefix just like `occur'.

View File

@ -8,12 +8,12 @@
(require 'latex-pretty-symbols nil t)
;;; Since current buffer is a LaTeX one, we can use `local-set-key'.
(local-set-keys
(ambrevar/local-set-keys
"C-c m" 'latex-article
"C-c l" 'latex-lstinline
"C-c o" 'latex-orgtbl)
(dolist (fun '(turn-on-orgtbl turn-on-skeleton-markers))
(dolist (fun '(turn-on-orgtbl ambrevar/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)
@ -24,7 +24,7 @@
;;; With TeXlive, the following packages are needed: psnfss, symbol, zapfding
(when (and (executable-find "dvipng") (require 'latex-math-preview nil t))
(setq latex-math-preview-cache-directory-for-insertion
(concat emacs-cache-folder "latex-math-preview-cache"))
(concat ambrevar/emacs-cache-folder "latex-math-preview-cache"))
(local-set-key (kbd "C-c p") 'latex-math-preview-expression)
(local-set-key (kbd "C-c j") 'latex-math-preview-insert-symbol)
(local-set-key (kbd "C-c C-j") 'latex-math-preview-last-symbol-again)
@ -32,7 +32,7 @@
(add-to-list 'latex-math-preview-usepackage-filter-alist '("color")))
;;; For some unknown reasons, `skeleton-end-hook' is set to nil in tex-mode.
;; (dolist (fun '(latex-set-compiler turn-on-orgtbl turn-on-skeleton-markers))
;; (dolist (fun '(latex-set-compiler turn-on-orgtbl ambrevar/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)

View File

@ -1,10 +1,10 @@
;;; Makefile
(define-keys makefile-mode-map
"C-c c" 'makefile-config
"C-c d" 'makefile-doc
"C-c m" 'makefile-main
"C-c s" 'makefile-c)
(ambrevar/define-keys makefile-mode-map
"C-c c" 'makefile-config
"C-c d" 'makefile-doc
"C-c m" 'makefile-main
"C-c s" 'makefile-c)
(define-skeleton makefile-main
"Insert root Makefile." nil

View File

@ -7,6 +7,6 @@
(define-key markdown-mode-map "\M-'" 'markdown-blockquote-region)
(add-hook 'markdown-mode-hook 'turn-on-newline-paragraph)
(add-hook 'markdown-mode-hook 'ambrevar/turn-on-newline-paragraph)
(provide 'init-markdown)

View File

@ -5,11 +5,11 @@
;;; Besides you can try extending `url-cookie-save-interval'.
;;; Nonetheless is mode is helpfull for syntax awareness.
(define-keys mediawiki-mode-map
"C-c o" 'mediawiki-browse
"M-g" nil ; This shadows M-g M-g.
"C-x C-s" 'save-buffer
"C-c M-s" 'mediawiki-save)
(ambrevar/define-keys mediawiki-mode-map
"C-c o" 'mediawiki-browse
"M-g" nil ; This shadows M-g M-g.
"C-x C-s" 'save-buffer
"C-c M-s" 'mediawiki-save)
(setq
mediawiki-site-alist

View File

@ -98,7 +98,7 @@ Default to unread messages if no"
(if mu4e-compose-fortune-p
(format "%s\n\n%s"
user-full-name
(call-process-to-string "fortune" "-s"))
(ambrevar/call-process-to-string "fortune" "-s"))
user-full-name)))
(add-hook 'mu4e-compose-pre-hook 'mu4e-add-fortune-signature)

View File

@ -1,8 +1,8 @@
;;; Nroff
(define-keys nroff-mode-map
"C-c C-b" 'nroff-bold
"C-c C-i" 'nroff-italic)
(ambrevar/define-keys nroff-mode-map
"C-c C-b" 'nroff-bold
"C-c C-i" 'nroff-italic)
;;; Skeletons
(define-skeleton nroff-bold "Bold text." nil "\\fB" @ _ "\\fR" @)

View File

@ -6,7 +6,7 @@
(setq
;; Move annoying babel folder.
org-babel-temporary-directory (concat emacs-cache-folder "babel")
org-babel-temporary-directory (concat ambrevar/emacs-cache-folder "babel")
;; Disable line splitting on M-RET.
org-M-RET-may-split-line '((default))
org-insert-heading-respect-content t
@ -27,7 +27,7 @@
;;; Agendas.
(add-to-list 'org-agenda-files "~/personal/todo/todo.org")
(defun org-switch-agenda-file (&optional other-window)
(defun ambrevar/org-switch-agenda-file (&optional other-window)
"Switch between org-agenda and the first org-agenda-files."
(interactive "P")
(if (and buffer-file-name
@ -40,16 +40,16 @@
(funcall (if other-window 'switch-to-buffer-other-window 'switch-to-buffer) b))
(funcall (if other-window 'find-file-other-window 'find-file) (car org-agenda-files))))))
(defun org-switch-agenda-file-other-window ()
"Like `org-switch-agenda-file' but use other window if possible."
(defun ambrevar/org-switch-agenda-file-other-window ()
"Like `ambrevar/org-switch-agenda-file' but use other window if possible."
(interactive)
(org-switch-agenda-file t))
(ambrevar/org-switch-agenda-file t))
;;; Set PDF association in Org-mode (original is 'default).
(setcdr (assoc "\\.pdf\\'" org-file-apps) 'emacs)
;;; Hooks.
(dolist (fun '(turn-off-linum turn-off-indent-tabs turn-off-auto-fill))
(dolist (fun '(ambrevar/turn-off-linum ambrevar/turn-off-indent-tabs turn-off-auto-fill))
(add-hook 'org-mode-hook fun))
(when (require 'org-contacts nil t)

View File

@ -1,7 +1,7 @@
;;; TeX
(dolist (fun '(turn-on-indent-tabs
;; turn-on-newline-paragraph
(dolist (fun '(ambrevar/turn-on-indent-tabs
;; ambrevar/turn-on-newline-paragraph
prettify-symbols-mode))
(add-hook 'tex-mode-hook fun))

View File

@ -16,27 +16,27 @@
(setq echo-keystrokes 0.5)
;;; Remember last cursor position.
(setq save-place-file (concat emacs-cache-folder "saveplace"))
(setq save-place-file (concat ambrevar/emacs-cache-folder "saveplace"))
(save-place-mode)
;;; 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)
;;; Network files
(setq url-cookie-file (concat emacs-cache-folder "url.cookies")
url-cache-directory (expand-file-name "url/cache" emacs-cache-folder))
(setq url-cookie-file (concat ambrevar/emacs-cache-folder "url.cookies")
url-cache-directory (expand-file-name "url/cache" ambrevar/emacs-cache-folder))
(with-eval-after-load 'nsm
(setq nsm-settings-file (concat emacs-cache-folder "network-security.data")))
(setq nsm-settings-file (concat ambrevar/emacs-cache-folder "network-security.data")))
;;; Bookmark file to cache folder.
(setq bookmark-default-file (concat emacs-cache-folder "emacs.bmk"))
(setq bookmark-default-file (concat ambrevar/emacs-cache-folder "emacs.bmk"))
;;; Recent files.
(setq recentf-save-file (concat emacs-cache-folder "recentf")
(setq recentf-save-file (concat ambrevar/emacs-cache-folder "recentf")
recentf-max-saved-items 40)
;;; Save M-: history.
(setq savehist-file (concat emacs-cache-folder "savehist"))
(setq savehist-file (concat ambrevar/emacs-cache-folder "savehist"))
(savehist-mode)
;;; Disable autosave features.
@ -45,7 +45,7 @@
;;; Place backup files in specific directory.
(setq backup-directory-alist
`(("." . ,(concat emacs-cache-folder "backups/"))))
`(("." . ,(concat ambrevar/emacs-cache-folder "backups/"))))
;;; Default mode
(setq-default major-mode 'text-mode)
@ -81,8 +81,8 @@
;;; 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.
(dolist (hook '(prog-mode-hook text-mode-hook))
(add-hook hook 'turn-on-column-number-mode)
(add-hook hook 'turn-off-line-number-mode)
(add-hook hook 'ambrevar/turn-on-column-number-mode)
(add-hook hook 'ambrevar/turn-off-line-number-mode)
(add-hook 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
@ -118,8 +118,8 @@
;;; WARNING: this can break some configuration files needing whitespaces at the
;;; end. This can also slow down saving on big files. Some modes (e.g. lisp) run
;;; `fmt' in their local hook, which is redundant with this.
;; (add-hook 'find-file-hook 'turn-on-fmt-before-save)
(add-hook 'find-file-hook 'turn-on-delete-trailing-whitespace)
;; (add-hook 'find-file-hook 'ambrevar/turn-on-fmt-before-save)
(add-hook 'find-file-hook 'ambrevar/turn-on-delete-trailing-whitespace)
;;; Cycle spacing instead of just-one-space. This frees M-\.
(global-set-key [remap just-one-space] 'cycle-spacing)
@ -148,12 +148,12 @@
;;; 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)
(global-set-keys
(ambrevar/global-set-keys
"s-h" 'windmove-left
"s-j" 'windmove-down
"s-k" 'windmove-up
"s-l" 'windmove-right))
(global-set-keys
(ambrevar/global-set-keys
"s-o" 'delete-other-windows
;; "s-w" 'other-window
"s-c" 'delete-window)
@ -169,7 +169,7 @@
(setq browse-url-generic-program (or
(executable-find (or (getenv "BROWSER") ""))
(when (executable-find "xdg-mime")
(let ((desktop-browser (call-process-to-string "xdg-mime" "query" "default" "text/html")))
(let ((desktop-browser (ambrevar/call-process-to-string "xdg-mime" "query" "default" "text/html")))
(substring desktop-browser 0 (string-match "\\.desktop" desktop-browser))))
(executable-find browse-url-mozilla-program)
(executable-find browse-url-firefox-program)
@ -189,9 +189,9 @@
;;; Default ispell dictionary. If not set, Emacs uses the current locale.
(setq ispell-dictionary "english")
(define-keys text-mode-map
"C-<f6>" 'ispell-change-dictionary
"<f6>" 'ispell-buffer)
(ambrevar/define-keys text-mode-map
"C-<f6>" 'ispell-change-dictionary
"<f6>" 'ispell-buffer)
;;; Show matching parenthesis
(show-paren-mode 1)
@ -233,10 +233,10 @@
(defun compile-last-command ()
(interactive)
(compile compile-command))
(define-keys prog-mode-map
"C-<f6>" 'compile
;; Do not use `recompile' since we want to change the compilation folder for the current buffer.
"<f6>" 'compile-last-command)
(ambrevar/define-keys prog-mode-map
"C-<f6>" 'compile
;; Do not use `recompile' since we want to change the compilation folder for the current buffer.
"<f6>" 'compile-last-command)
;;; REVIEW: Bug 26658 reports that cc-modes mistakenly does not make use of prog-mode-map.
;;; The following line is a suggested work-around.
@ -266,7 +266,7 @@
;; might never be saved. See
;; https://debbugs.gnu.org/cgi/bugreport.cgi?bug=28943.
desktop-auto-save-timeout 5
desktop-dirname (expand-file-name "desktop" emacs-cache-folder)
desktop-dirname (expand-file-name "desktop" ambrevar/emacs-cache-folder)
desktop-path (list desktop-dirname)
;; desktop-restore-eager 4 ; Can be annoying as you don't have your last-loaded buffers immediately.
desktop-load-locked-desktop 'ask
@ -294,8 +294,8 @@
;;; Skeleton settings
;;; Do not expand abbrevs in skeletons.
(setq-default skeleton-further-elements '((abbrev-mode nil)))
(turn-on-skeleton-markers)
(global-set-keys
(ambrevar/turn-on-skeleton-markers)
(ambrevar/global-set-keys
"C->" 'skeleton-next-position
"C-<" 'skeleton-previous-position)
@ -313,7 +313,7 @@
(global-unset-key (kbd "C-<down-mouse-1>"))
;;; Scroll zooming.
(global-set-keys
(ambrevar/global-set-keys
"C-<wheel-down>" 'text-scale-decrease
"C-<mouse-5>" 'text-scale-decrease
"C-<wheel-up>" 'text-scale-increase
@ -354,15 +354,15 @@
("Africa/Nairobi" "Uganda")))
;;; Tramp
(setq tramp-persistency-file-name (concat emacs-cache-folder "tramp")
(setq tramp-persistency-file-name (concat ambrevar/emacs-cache-folder "tramp")
tramp-backup-directory-alist backup-directory-alist)
;;; Frame title
(setq frame-title-format (concat "%b" (unless (daemonp) " [serverless]")))
;;; Initial scratch buffer message.
(require 'functions) ; For `fortune-scratch-message'.
(let ((fortune (fortune-scratch-message)))
(require 'functions) ; For `ambrevar/fortune-scratch-message'.
(let ((fortune (ambrevar/fortune-scratch-message)))
(when fortune
(setq initial-scratch-message fortune)))

View File

@ -1 +1 @@
((nil . ((fmt-inhibit-p . t))))
((nil . ((ambrevar/fmt-inhibit-p . t))))