Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
; Disable double-buffering; we don't need it and it seems to make things
; slightly laggier.
(modify-frame-parameters nil '((inhibit-double-buffering . t)))
(setq default-frame-parameters '((inhibit-double-buffering . t)))
; Disable the toolbar
(tool-bar-mode -1)
; Reopen the files that were open in the previous session
(desktop-save-mode 1)
; Never pop up dialog boxes
(setq use-dialog-box nil)
; We use version control, so don't create backup or autosave files.
(setq make-backup-files nil)
(setq auto-save-default nil)
; Don't create lockfiles.
(setq create-lockfiles nil)
; Automatically revert files to the on-disk contents
(global-auto-revert-mode 1)
; Wrap words rather than characters
(setq-default word-wrap t)
; Don't truncate lines
(setq-default truncate-lines nil)
; When reaching the end, scroll by one line instead of half the viewport
(setq scroll-step 1)
; Make mousewheel scroll three lines at a time
(setq mouse-wheel-scroll-amount '(3 ((shift) . 1)))
; Don't accelerate scrolling
(setq mouse-wheel-progressive-speed nil)
; Scroll the window under the mouse cursor
(setq mouse-wheel-follow-mouse 't)
; Highlight matching parentheses with no delay
(setq show-paren-delay 0)
(show-paren-mode 1)
; Open URLs in Chrome
(setq browse-url-browser-function 'browse-url-generic)
(setq browse-url-generic-program "google-chrome")
; This is C-<return> by default, but we need that for org-mode
(setq cua-rectangle-mark-key (kbd "C-S-<return>"))
; Don't clear the region after copying
(setq cua-keep-region-after-copy t)
; Must be done after setq cua-rectangle-mark-key
(cua-mode t)
; Enable ido
(ido-mode t)
(ido-everywhere t)
; Enable ido-ubiquitous
(setq load-path (cons "~/opt/ido-ubiquitous" load-path))
(require 'ido-ubiquitous)
(ido-ubiquitous t)
; Enable smex
(setq load-path (cons "~/opt/smex" load-path))
(require 'smex)
(setq smex-save-file "~/.cache/emacs/smex-items")
(smex-initialize)
; Access the TODO menu in fewer keystrokes
(global-set-key (kbd "C-t") 'org-todo)
(global-set-key (kbd "C-c a") 'org-agenda)
(global-set-key (kbd "M-q") 'switch-to-buffer)
(global-set-key (kbd "C--") 'text-scale-decrease)
(global-set-key (kbd "C-=") 'text-scale-increase)
(global-set-key (kbd "C-o") 'browse-url-at-point)
(global-set-key (kbd "C-a") 'mark-whole-buffer)
(global-set-key (kbd "C-s") 'save-buffer)
(global-set-key (kbd "C-w") 'kill-this-buffer)
(global-set-key (kbd "C-f") 'isearch-forward)
(global-set-key (kbd "C-b") 'isearch-backward)
(global-set-key (kbd "<f3>") 'isearch-repeat-forward)
(global-set-key (kbd "S-<f3>") 'isearch-repeat-backward)
(global-set-key (kbd "<escape>") 'keyboard-escape-quit)
(global-set-key (kbd "M-x") 'smex)
(global-set-key (kbd "M-X") 'smex-major-mode-commands) ; commands relevant to active major mode
(define-key isearch-mode-map (kbd "C-f") 'isearch-repeat-forward)
(define-key isearch-mode-map (kbd "C-b") 'isearch-repeat-backward)
;;; org-mode
; It's way too easy to accidentally open links with mouse-1; you can still
; open them with mouse-2 or mouse-3. Unfortunately, setting this breaks
; activate-bullets.
;
; Needs to be set before org-mode is loaded.
(setq org-mouse-1-follows-link nil)
(setq load-path (cons "~/opt/org-mode/lisp" load-path))
(require 'org)
; Also load both .org_archive files with org-mode
(add-to-list 'auto-mode-alist '("\\.org_archive$" . org-mode))
; "Make point visible, and do insertion/deletion if it is
; adjacent to visible text and the change feels predictable.
; Never delete a previously invisible character or add in the
; middle or right after an invisible region. Basically, this
; allows insertion and backward-delete right before ellipses."
(setq org-catch-invisible-edits 'smart)
; http://orgmode.org/manual/Clean-view.html
(setq org-startup-indented t)
;(setq org-ellipsis " ↡↡↡")
(setq org-ellipsis " ↴↴↴")
(setq org-todo-keywords
; keywords following the "|" are considered complete
;
; ! = timestamp
; @ = note with a timestamp
; /! = timestamp even if destination keyword has no logging configured
'((sequence "TODO(t!)" "WAIT(w@/!)" "|" "DONE(d!)" "CANCELED(c!)")))
; http://orgmode.org/manual/Weekly_002fdaily-agenda.html
(setq org-agenda-include-diary t)
(setq org-agenda-files '(
"~/wiki/tasks.org"
"~/wiki/events.org"
))
; Using ido for refiling is buggy: https://lists.gnu.org/archive/html/emacs-orgmode/2016-05/msg00665.html
; Use ido for refiling
;(setq org-completion-use-ido t)
; Needed to use ido for refiling
;(setq org-outline-path-complete-in-steps nil)
; Make org-refile work on files
(setq org-refile-use-outline-path 'file)
; Make org-refile use agenda files as targets
(setq org-refile-targets
'((org-agenda-files :maxlevel . 1)))
; Refile to the top instead of the bottom
(setq org-reverse-note-order t)
(defun org-save-all-org-buffers-quietly ()
(save-some-buffers t (lambda () (derived-mode-p 'org-mode)))
(when (featurep 'org-id) (org-id-locations-save)))
; Save all modified org buffers very frequently, because otherwise it's easy to
; accidentally leave things unsaved after refilings or other changes.
(run-at-time nil 15 'org-save-all-org-buffers-quietly)
(defun load-org-modules ()
; Merely loading org-mouse breaks clicking inside a region: clicking
; should clear the region; with org-mouse loaded, the region is truncated
; to the point.
;(add-to-list 'org-modules 'org-mouse)
)
(eval-after-load "org" '(load-org-modules))
(setq load-path (cons "~/opt/org-bullets" load-path))
(require 'org-bullets)
; Avoid using ✸ because it increases the line height
(setq org-bullets-bullet-list '("" ""))
(setq org-mouse-features '(context-menu activate-stars activate-bullets activate-checkboxes))
(add-hook 'org-mode-hook
(lambda ()
(setq truncate-lines nil)
(org-bullets-mode 1)
; org-mode binds ctrl-a to org-beginning-of-line, but we don't need it
; because we have Home and End.
(local-set-key (kbd "C-a") 'mark-whole-buffer)
(auto-revert-mode 1)
)
)
;;; fonts and colors
; Needed for the org-headline-done below to work
(setq org-fontify-done-headline t)
(setq org-todo-keyword-faces
'(("CANCELED" :foreground "LavenderBlush4" :weight bold)
("WAIT" :foreground "#EB902C" :weight bold)
("DONE" :foreground "LavenderBlush4" :weight bold)
("TODO" :foreground "#0FAE2F" :weight bold)))
; Use the system-configured monospace font
(set-face-attribute 'default nil :font "Monospace-10.5")
(custom-set-faces
'(default ((t (:background "#FFF7E1")))) ; Light yellow background
'(org-hide ((t (:foreground "#FFF7E1")))) ; Make the invisible asterisks match the background
'(region ((t (:background "#FFCC33")))) ; Orange text selection
; Make all outline levels black so we don't mentally associate outline depth with anything
'(outline-1 ((t (:foreground "#000000"))))
'(outline-2 ((t (:foreground "#000000"))))
'(outline-3 ((t (:foreground "#000000"))))
'(outline-4 ((t (:foreground "#000000"))))
'(outline-5 ((t (:foreground "#000000"))))
'(outline-6 ((t (:foreground "#000000"))))
'(org-ellipsis ((t (:foreground "#888888"))))
'(org-headline-done ((t (:foreground "LavenderBlush4")))) ; Gray out DONE items in files
'(org-agenda-done ((t (:foreground "LavenderBlush4")))) ; Gray out DONE items in agenda
)
;;; interactive functions
; http://xahlee.org/emacs/emacs_make_modern.html
(defun toggle-line-spacing ()
"Toggle line spacing between no extra space to extra half line height."
(interactive)
(if (eq line-spacing nil)
; add some height between lines
(setq-default line-spacing 0.25)
; no extra height between lines
(setq-default line-spacing nil))
(redraw-display))
(setq-default line-spacing 0.25)
; Emacs' Ctrl-backspace runs backward-kill-word which deletes too much, so use
; this replacement from http://stackoverflow.com/questions/28221079/ctrl-backspace-in-emacs-deletes-too-much
(defun my-kill-back ()
(interactive)
(if (bolp)
; beginnning of line, just delete 1
(backward-delete-char 1)
(if (string-match "[^[:space:]]" (buffer-substring (point-at-bol) (point)))
; There's a word on the line, delete it
(backward-kill-word 1)
(delete-region (point-at-bol) (point))))) ; all whitespace, delete it
(global-set-key [C-backspace] 'my-kill-back)
Owner

ivan commented Apr 8, 2017

Linked to from https://ludios.org/links/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment