Continue moving to the Org config

This commit is contained in:
Gergely Polonkai 2018-07-30 19:52:16 +02:00
parent 329a86937d
commit 239e1742a4
2 changed files with 884 additions and 546 deletions

View File

@ -1,6 +1,6 @@
* Emacs configuration * Emacs configuration
** Configure ~use-package~ ** Configure ~use-package~ and preload ~bind-key~
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(unless (package-installed-p 'use-package) (unless (package-installed-p 'use-package)
@ -11,6 +11,8 @@
use-package-verbose t) use-package-verbose t)
(require 'use-package) (require 'use-package)
(use-package bind-key)
#+END_SRC #+END_SRC
** Set up my personal keymap ** Set up my personal keymap
@ -66,6 +68,18 @@ I set it up early so I can use it in ~use-package~ calls immediately.
(mapcar (lambda (x) (and (stringp x) x)) var)))))) (mapcar (lambda (x) (and (stringp x) x)) var))))))
#+END_SRC #+END_SRC
** Check if we are running under Termux
We need to do things differently, if so.
#+BEGIN_SRC emacs-lisp
(defun termux-p ()
"Check if Emacs is running under Termux."
(string-match-p
(regexp-quote "/com.termux/")
(expand-file-name "~")))
#+END_SRC
** Misc text manipulation functions ** Misc text manipulation functions
*** Delete the current line *** Delete the current line
@ -605,6 +619,16 @@ Copied from https://ryuslash.org/posts/C-d-to-close-eshell.html
`(gpolonkai/idm-get-field-for-account ,account 'account-id)) `(gpolonkai/idm-get-field-for-account ,account 'account-id))
#+END_SRC #+END_SRC
** Automatically zone out after 60 seconds
#+BEGIN_SRC emacs-lisp
(defun gpolonkai/zone-enable ()
"Enable zoning out."
(interactive)
(zone-when-idle 60)
(message "I will zone out after idling for 60 seconds."))
#+END_SRC
* UI preferences * UI preferences
** Tweak window chrome ** Tweak window chrome
@ -625,9 +649,24 @@ Also, maximise the frame.
** Set the default font and configure font resizing ** Set the default font and configure font resizing
Before this can be used, make sure the [[https://zhm.github.io/symbola/][Symbola]] font is installed.
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(set-face-attribute 'default t :font "Hack-10") (set-face-attribute 'default t :font "Hack-10")
(set-frame-font "Hack-10" nil t) (set-frame-font "Hack-10" nil t)
(defun --set-emoji-font (frame)
"Adjust the font setting of FRAME so Emacs can display Emoji properly."
(when (fboundp 'set-fontset-font)
(if (eq system-type 'darwin)
;; For NS/Cocoa
(set-fontset-font t 'symbol
(font-spec :family "Apple Color Emoji")
frame 'prepend)
;; For Linux
(set-fontset-font t 'symbol
(font-spec :family "Symbola")
frame 'prepend))))
#+END_SRC #+END_SRC
* Set up global minor modes provided by Emacs * Set up global minor modes provided by Emacs
@ -697,8 +736,160 @@ Because we can.
`((".*" ,temporary-file-directory t)))) `((".*" ,temporary-file-directory t))))
#+END_SRC #+END_SRC
** ~whitespace~
~whitespace-mode~ is turned on by default, and can be toggled with ~F10~.
#+BEGIN_SRC emacs-lisp
(defun prevent-whitespace-mode-for-magit ()
"Prevent whitespace-mode from running in magit derived modes."
(not (derived-mode-p 'magit-mode)))
(use-package whitespace
:demand
:config
(add-function :before-while whitespace-enable-predicate 'prevent-whitespace-mode-for-magit)
(global-whitespace-mode 1)
(setq whitespace-line-column 100)
:bind
(([f10] . whitespace-mode)
([(shift f10)] . global-whitespace-mode)
:map gpolonkai/pers-map
("w" . whitespace-cleanup)))
#+END_SRC
** ~eshell~
#+BEGIN_SRC emacs-lisp
(use-package eshell
:config
(add-hook 'eshell-mode-hook
(lambda () (local-set-key (kbd "C-d") #'eshell-C-d)))
:bind
(:map gpolonkai/pers-map
("e" . eshell)))
#+END_SRC
** ~saveplace~
#+BEGIN_SRC emacs-lisp
;; Save place
(use-package saveplace
:config
(setq-default save-place t)
(setq save-place-file (expand-file-name ".places" user-emacs-directory)))
#+END_SRC
** ID manager
Manage credentials, AKA password manager.
#+BEGIN_SRC emacs-lisp
(use-package id-manager
:config
(setq idm-database-file (expand-file-name "idm-db.gpg" user-emacs-directory))
:bind
(:map gpolonkai/pers-map
("i" . idm-open-list-command)))
#+END_SRC
** EDiff
#+BEGIN_SRC emacs-lisp
(use-package ediff
:init
(setq-default ediff-merge-split-window-function 'split-window-horizontally
ediff-split-window-function 'split-window-vertically
ediff-window-setup-function 'ediff-setup-windows-plain))
#+END_SRC
** Automatically revert changed files
…unless they are modified, of course.
#+BEGIN_SRC emacs-lisp
(use-package autorevert
:config
(global-auto-revert-mode 1))
#+END_SRC
** Eww
For in-Emacs browsing needs.
#+BEGIN_SRC emacs-lisp
(use-package eww
:config
(setq eww-search-prefix "https://www.google.com/?q="))
#+END_SRC
** Electric indent mode
#+BEGIN_SRC emacs-lisp
(use-package electric
:config
;; This seems to be the default, but lets make sure…
(electric-indent-mode 1))
#+END_SRC
** Save history
#+BEGIN_SRC emacs-lisp
(use-package savehist
:config
(savehist-mode 1))
#+END_SRC
** Web jump
#+BEGIN_SRC emacs-lisp
(use-package webjump
:bind
(:map gpolonkai/pers-map
("j" . webjump)))
#+END_SRC
** Which function am I in?
#+BEGIN_SRC emacs-lisp
(use-package which-func
:config
(add-hook 'prog-mode-hook
(lambda ()
(if (fboundp 'which-function-mode)
(which-function-mode)
(which-func-mode))))
(setq which-func-unknown "∅"))
#+END_SRC
** Fortune cookies
The cookies are from the Hungarian version an ancient MS-DOS based program called ~TAGLINE~.
#+BEGIN_SRC emacs-lisp
(use-package cookie1
:demand t
:config
(setq cookie-file (concat user-emacs-directory "fortune-cookies.txt"))
:bind
(:map gpolonkai/pers-map
("k" . cookie)))
#+END_SRC
* ~use-package~ packages * ~use-package~ packages
** Automatically upgrade packages every week
#+BEGIN_SRC emacs-lisp
(use-package auto-package-update
:config
(setq auto-package-update-interval 7
auto-package-update-delete-old-versions t)
;; Lets do this in after-init-hook, as use-package invocations may modify
;; the list of installed packages
(add-hook 'after-init-hook 'auto-package-update-maybe))
#+END_SRC
** Nyanyanyanyanya ** Nyanyanyanyanya
*** Nyan-cat style position marker *** Nyan-cat style position marker
@ -736,6 +927,109 @@ Unfortunately, this works only in a graphical mode.
(setq zone-programs (vconcat zone-programs [zone-nyan])))) (setq zone-programs (vconcat zone-programs [zone-nyan]))))
#+END_SRC #+END_SRC
** Eye candy
*** Smart mode-line
#+BEGIN_SRC emacs-lisp
(use-package smart-mode-line
:after
org
:config
(add-to-list 'sml/replacer-regexp-list
'("^~/Projects/" ":Proj:")
t)
(add-to-list 'sml/replacer-regexp-list
'("^~/Projektek/" ":Proj:")
t)
(add-to-list 'sml/replacer-regexp-list
(list (concat "^" (regexp-quote user-documents-directory))
":Doc:")
t)
(add-to-list 'sml/replacer-regexp-list
'("^:Proj:jekyll/gergelypolonkai.github.io/" ":Blog:")
t)
(add-to-list 'sml/replacer-regexp-list
(list "^:Proj:python/" ":Proj:Py:")
t)
(sml/setup)
(require 'cl-lib)
(setq-default header-line-format
'(""
mode-line-mule-info
mode-line-client
mode-line-modified
mode-line-remote
mode-line-frame-identification
mode-line-buffer-identification
sml/pos-id-separator
(vc-mode vc-mode)
mode-line-position))
(delete '(vc-mode vc-mode) mode-line-format)
(delete 'mode-line-frame-identification mode-line-format)
(delete 'mode-line-buffer-identification mode-line-format)
(delete 'mode-line-position mode-line-format)
(delete 'mode-line-mule-info mode-line-format)
(delete 'mode-line-modified mode-line-format)
(delete 'mode-line-client mode-line-format)
(delete 'mode-line-remote mode-line-format)
;; Add sml/pre-id-separator after mode-line-front-space
(let* ((front-space-position (1+ (cl-position 'mode-line-front-space mode-line-format)))
(mode-line-rest (nthcdr front-space-position mode-line-format))
(mode-line-beg (cl-subseq mode-line-format 0 front-space-position)))
(setq-default mode-line-format (nconc mode-line-beg
(list sml/pre-id-separator)
mode-line-rest))))
#+END_SRC
*** Powerline theme for ~smart-mode-line~
#+BEGIN_SRC emacs-lisp
(use-package smart-mode-line-powerline-theme
:init
(setq-default sml/theme 'powerline))
#+END_SRC
*** Spinner, e.g. to display running background tasks
#+BEGIN_SRC emacs-lisp
(use-package spinner)
#+END_SRC
*** Beacon
Highlight point. Sometimes its not easy to see.
#+BEGIN_SRC emacs-lisp
(use-package beacon
:demand
:config
(beacon-mode 1)
:bind
(:map gpolonkai/pers-map
("b" . beacon-blink)))
#+END_SRC
*** Display the status of the last command in the fringe of EShell
#+BEGIN_SRC emacs-lisp
(when (display-graphic-p)
(use-package eshell-fringe-status
:config
(add-hook 'eshell-mode-hook 'eshell-fringe-status-mode)))
#+END_SRC
*** Extras for the EShell prompt
#+BEGIN_SRC emacs-lisp
(use-package eshell-prompt-extras
:config
(with-eval-after-load "esh-opt"
(autoload 'epe-theme-lambda "eshell-prompt-extras")
(setq eshell-highlight-prompt nil
eshell-prompt-function 'epe-theme-lambda)))
#+END_SRC
** Highlight the current line ** Highlight the current line
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
@ -806,6 +1100,12 @@ Because one is never enough.
("C-c m =" . mc/compare-chars))) ("C-c m =" . mc/compare-chars)))
#+END_SRC #+END_SRC
*** Add extra cursors via ~ace-jump~
#+BEGIN_SRC emacs-lisp
(use-package ace-mc)
#+END_SRC
** Magit ** Magit
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
@ -825,6 +1125,575 @@ I also want FlySpell to be enabled during Git commit message editing.
(add-hook 'git-commit-mode-hook 'turn-on-flyspell) (add-hook 'git-commit-mode-hook 'turn-on-flyspell)
#+END_SRC #+END_SRC
** Zone
#+BEGIN_SRC emacs-lisp
(use-package zone
:demand
:config
(zone-when-idle 60)
:bind
(:map gpolonkai/pers-map
("zi" . gpolonkai/zone-enable)
("zq" . zone-leave-me-alone)))
#+END_SRC
** Origami
#+BEGIN_SRC emacs-lisp
(use-package origami
:demand
:config
(define-prefix-command 'origami-mode-map)
(define-key ctl-x-map (kbd "z") 'origami-mode-map)
(global-origami-mode)
:bind
(:map origami-mode-map
("o" . origami-open-node)
("O" . origami-open-node-recursively)
("c" . origami-close-node)
("C" . origami-close-node-recursively)
("a" . origami-toggle-node)
("A" . origami-recursively-toggle-node)
("R" . origami-open-all-nodes)
("M" . origami-close-all-nodes)
("v" . origami-show-only-node)
("k" . origami-previous-fold)
("j" . origami-forward-fold)
("x" . origami-reset)))
#+END_SRC
** Smart parens
#+BEGIN_SRC emacs-lisp
(use-package smartparens
:demand
:config
(show-smartparens-global-mode t)
(add-hook 'prog-mode-hook
'turn-on-smartparens-strict-mode)
(add-hook 'markdown-mode-hook
'turn-on-smartparens-strict-mode)
:bind
(([f9] . smartparens-strict-mode)
("C-c s u" . sp-unwrap-sexp)
("C-c s k" . sp-kill-sexp)))
#+END_SRC
** Projectile
#+BEGIN_SRC emacs-lisp
(use-package projectile
:pin melpa-stable
:config
(projectile-global-mode t))
#+END_SRC
*** Repository-based ToDo management with Org mode
#+BEGIN_SRC emacs-lisp
(use-package org-projectile)
#+END_SRC
** Drag stuff
To move lines around.
#+BEGIN_SRC emacs-lisp
(use-package drag-stuff
:config
(drag-stuff-global-mode t)
(drag-stuff-define-keys))
#+END_SRC
** Ace window
Besides its standard functionality, I also make add key bindings for burying or scrolling another
window.
#+BEGIN_SRC emacs-lisp
(use-package ace-window
:config
(setq aw-background nil
aw-dispatch-always t)
(add-to-list 'aw-dispatch-alist
'(?s gpolonkai/scroll-window-up " Scroll window up")
t)
(add-to-list 'aw-dispatch-alist
'(?S gpolonkai/scroll-window-down " Scroll window down")
t)
(add-to-list 'aw-dispatch-alist
'(?q gpolonkai/bury-window " Bury (quit) window")
t)
:bind
(:map ctl-x-map
("o" . ace-window)))
#+END_SRC
** Avy
#+BEGIN_SRC emacs-lisp
(use-package avy
:demand
:config
(avy-setup-default)
:bind
(("M-g c" . avy-goto-char)
("C-'" . avy-goto-char-2)
("M-g f" . avy-goto-line)
("M-g w" . avy-goto-word-1)
("M-g e" . avy-goto-word-0)))
#+END_SRC
** Focus mode
It is similar to narrow mode, except the narrowing part; it dims everything outside of the current
context.
#+BEGIN_SRC emacs-lisp
(use-package focus
:bind
(([f8] . focus-mode)))
#+END_SRC
** Command logging mode
For occasional screen casting recordings.
#+BEGIN_SRC emacs-lisp
(use-package command-log-mode)
#+END_SRC
** Emamux
For controlling tmux from within Emacs.
#+BEGIN_SRC emacs-lisp
(use-package emamux)
#+END_SRC
** Use StackExchange sites in an Emacs window
#+BEGIN_SRC emacs-lisp
(use-package sx
:demand
:bind
(:map gpolonkai/pers-map
("qi" . sx-inbox)
("qs" . sx-search)))
#+END_SRC
** Goto last change
#+BEGIN_SRC emacs-lisp
(use-package goto-last-change
:bind
(("M-g /" . goto-last-change)))
#+END_SRC
** Rainbow mode
To highlight colours based on their name or hex code.
#+BEGIN_SRC emacs-lisp
(use-package rainbow-mode
:config
(add-hook 'css-mode-hook 'rainbow-mode)
(add-hook 'scss-mode-hook 'rainbow-mode)
(add-hook 'sass-mode 'rainbow-mode))
#+END_SRC
** Zygospore
Toggle other windows for maximum focus. When focus is no longer needed, they can be toggled back.
~C-x 1~ is conveniently bound to it.
#+BEGIN_SRC emacs-lisp
(use-package zygospore
:bind
(:map ctl-x-map
("1" . zygospore-toggle-delete-other-windows)))
#+END_SRC
** Kanban board
#+BEGIN_SRC emacs-lisp
(use-package kanban)
#+END_SRC
** Highlight dired buffer by file size, modified time, git status
#+BEGIN_SRC emacs-lisp
(use-package dired-k
:bind
(:map dired-mode-map
("K" . dired-k)))
#+END_SRC
** Show number of matches in the mode line while searching
#+BEGIN_SRC emacs-lisp
(use-package anzu
:config
(global-anzu-mode 1))
#+END_SRC
** Gradually expand region
#+BEGIN_SRC emacs-lisp
(use-package expand-region
:bind
(("C-@" . er/expand-region)))
#+END_SRC
** Read and Edit MediaWiki pages in an Emacs window
#+BEGIN_SRC emacs-lisp
(use-package mediawiki
:after
id-manager
:config
(add-to-list 'mediawiki-site-alist
'("WikEmacs"
"http://wikemacs.org/wiki/"
(gpolonkai/idm-get-id-for-account "WikEmacs")
(gpolonkai/idm-get-password-for-account "WikEmacs"))))
#+END_SRC
** Display unread GitHub notification count in the mode line
#+BEGIN_SRC emacs-lisp
(use-package github-notifier
:after
id-manager
:config
(setq github-notifier-token (gpolonkai/idm-get-password-for-account "GitHub"))
(github-notifier-mode))
#+END_SRC
** Interact with GitHub gists
#+BEGIN_SRC emacs-lisp
(use-package gist)
#+END_SRC
** An Emacs Dashboard
#+BEGIN_SRC emacs-lisp
(use-package dashboard
:after
projectile
:config
(add-to-list 'dashboard-items '(projects . 5) t)
(dashboard-setup-startup-hook))
#+END_SRC
* Make programming a bit easier
** Electric case
Insert snake_case and camelCase without using the Shift key. It is automatically enabled in C
mode.
#+BEGIN_SRC emacs-lisp
(use-package electric-case
:config
(add-hook 'c-mode-hook 'electric-case-c-init))
#+END_SRC
** Electric operator
Automatically add spaces around operators.
#+BEGIN_SRC emacs-lisp
(use-package electric-operator
:config
(add-hook 'c-mode-common-hook 'electric-operator-mode)
;; Apply electric-operator-mode to vala-mode, too
(apply #'electric-operator-add-rules-for-mode 'vala-mode
electric-operator-prog-mode-rules))
#+END_SRC
** Yasnippets
#+BEGIN_SRC emacs-lisp
(use-package yasnippet
:demand
:config
(yas-global-mode 1)
(add-hook 'post-command-hook 'sachachua/change-cursor-color-when-can-expand))
#+END_SRC
*** Extra snippets for Vala
#+BEGIN_SRC emacs-lisp
(use-package vala-snippets
:after
yasnippet)
#+END_SRC
*** Miscellanous extra snippets
#+BEGIN_SRC emacs-lisp
(use-package yasnippet-snippets)
#+END_SRC
** Colourful delimiters
#+BEGIN_SRC emacs-lisp
(use-package rainbow-delimiters
:config
(add-hook 'prog-mode-hook
#'rainbow-delimiters-mode))
#+END_SRC
** REST Client
#+BEGIN_SRC emacs-lisp
(use-package restclient)
#+END_SRC
** Highlight current symbol
A big help during refactoring.
#+BEGIN_SRC emacs-lisp
(use-package auto-highlight-symbol
:config
(global-auto-highlight-symbol-mode t))
#+END_SRC
** Make ReallyLongCamelCaseWords more readable
#+BEGIN_SRC emacs-lisp
(use-package glasses
:config
(add-hook 'prog-mode-hook 'glasses-mode))
#+END_SRC
* FlyCheck
#+BEGIN_SRC emacs-lisp
(use-package flycheck
:config
(global-flycheck-mode))
#+END_SRC
** FlyCheck for pkg-config files
#+BEGIN_SRC emacs-lisp
(use-package flycheck-pkg-config)
#+END_SRC
* Org mode
This is a big one; I use a lot of customisation here.
#+BEGIN_SRC emacs-lisp
(use-package org
:demand
:init
(require 'xdg-paths)
(setq-default org-crypt-key "B0740C4C"
org-default-notes-file (concat user-documents-directory
(convert-standard-filename
"/orgmode/notes.org"))
org-directory (concat user-documents-directory
(convert-standard-filename "/orgmode/"))
org-agenda-files (concat user-documents-directory
(convert-standard-filename
"/orgmode/agenda_files"))
org-ellipsis "…#"
org-startup-folded 'content
org-mobile-directory (concat user-documents-directory
(convert-standard-filename
"/orgmode/mobile/"))
org-mobile-inbox-for-pull (concat
user-documents-directory
(convert-standard-filename
"/orgmode/from-mobile.org"))
org-log-done 'time
org-src-preserve-indentation t
org-log-into-drawer t
org-tags-column 0
org-startup-indented t
org-special-ctrl-a/e t)
:config
(require 'ox-md)
(unless (boundp 'org-capture-templates)
(setq org-capture-templates nil))
(add-to-list 'org-capture-templates
'("p" "Blog post"
entry (file+olp+datetree (concat org-directory "blog.org"))
"* %^{Title} :blog:\n :PROPERTIES:\n :on: %T\n :END:\n %i%?"))
(add-to-list 'org-capture-templates
'("g" "GT2 note"
entry (file+headline (concat org-directory "gt2-notes.org")
"Captures")
"** %^{Title}\n :PROPERTIES:\n :on: %T\n :END:\n %i%?"))
(setq org-time-stamp-formats '("<%Y-%m-%d>" . "<%Y-%m-%d %H:%M>")
org-todo-keywords '((sequence "TODO(t)"
"DOING(w@/!)"
"BLOCKED(b@/!)"
"|"
"CANCELED(c@/!)"
"REVIEW(r@/!)"
"DONE(d@/!)"))
org-goto-interface 'outline-path-completion
org-goto-max-level 10
org-html-checkbox-type 'unicode
org-html-checkbox-types
'((unicode (on . "<span class=\"task-done\">☑</span>")
(off . "<span class=\"task-todo\">☐</span>")
(trans . "<span class=\"task-in-progress\">▣</span>")))
org-src-window-setup 'current-window)
(add-hook 'ediff-select-hook 'f-ediff-org-unfold-tree-element)
(add-hook 'ediff-unselect-hook 'f-ediff-org-fold-tree)
:bind
(:map gpolonkai/pers-map
("a" . org-agenda-list)
("c" . org-capture)
("l" . org-store-link)
:map org-mode-map
("SPC" . org-space-key)
("C-c l" . org-toggle-link-display)
("C-a" . gpolonkai/move-to-beginning-of-line)
("C-e" . gpolonkai/move-to-end-of-line)))
#+END_SRC
** Org bullets
To display fancy bullets in graphics mode.
#+BEGIN_SRC emacs-lisp
(use-package org-bullets
:init
(add-hook 'org-mode-hook
(lambda ()
(if (display-graphic-p) org-bullets-mode))))
#+END_SRC
** Show a random ToDo every hour
#+BEGIN_SRC emacs-lisp
(use-package org-random-todo
:demand
:config
;; Dont bug me too often…
(setq org-random-todo-how-often 3600)
:bind
(:map gpolonkai/pers-map
("r" . org-random-todo)))
#+END_SRC
* Git & Co.
** Git status on the fringe
In graphical modes we use ~git-gutter-fringe~, and ~git-gutter~ otherwise.
#+BEGIN_SRC emacs-lisp
;; Git gutter
;; If we are in text-only mode, there is no fringe.
(let ((gitgutter-package
(if (display-graphic-p)
"git-gutter-fringe"
"git-gutter")))
(eval `(use-package ,gitgutter-package
:demand
:config
(global-git-gutter-mode t)
:bind
(:map gpolonkai/pers-map
("gg" . git-gutter:update-all-windows)
("gn" . git-gutter:next-hunk)
("gp" . git-gutter:previous-hunk)))))
#+END_SRC
** Git messenger
AKA blame current line.
#+BEGIN_SRC emacs-lisp
(use-package git-messenger
:bind
(:map gpolonkai/pers-map
("gm" . git-messenger:popup-message)))
#+END_SRC
** Git time machine
See previous versions of the current file.
#+BEGIN_SRC emacs-lisp
(use-package git-timemachine
:bind
(([f6] . git-timemachine-toggle)))
#+END_SRC
* Company & Co.
#+BEGIN_SRC emacs-lisp
(use-package company
:config
(setq company-idle-delay nil
company-frontends '(company-pseudo-tooltip-frontend
company-echo-metadata-frontend)
company-dabbrev-downcase nil)
(put 'company-clang-arguments 'safe-local-variable #'nil-or-list-of-strings-p)
(global-company-mode))
#+END_SRC
** Company completion based on local C headers
#+BEGIN_SRC emacs-lisp
(use-package company-c-headers)
#+END_SRC
** Company mode in the shell
#+BEGIN_SRC emacs-lisp
(use-package company-shell)
#+END_SRC
** REST Client completion via Company
#+BEGIN_SRC emacs-lisp
(use-package company-restclient)
#+END_SRC
** Insert Emoji with Company
#+BEGIN_SRC emacs-lisp
(use-package company-emoji
:after
company
:init
(--set-emoji-font nil)
:config
(add-to-list 'company-backends 'company-emoji)
(add-hook 'after-make-frame-functions
'--set-emoji-font))
#+END_SRC
** Anaconda backend for Company
#+BEGIN_SRC emacs-lisp
(use-package company-anaconda
:after
company
:config
(add-to-list 'company-backends 'company-anaconda))
#+END_SRC
** Web mode (~web-mode~ and ~emmet-mode~, too) backend for Company
#+BEGIN_SRC emacs-lisp
(use-package company-web
:config
(require 'company-web-html))
#+END_SRC
* Helm & Co. * Helm & Co.
** Helm ** Helm
@ -1100,3 +1969,17 @@ I also want FlySpell to be enabled during Git commit message editing.
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(use-package gitignore-mode) (use-package gitignore-mode)
#+END_SRC #+END_SRC
** ~po-mode~
#+BEGIN_SRC emacs-lisp
(use-package po-mode
:mode "\\.po\\'")
#+END_SRC
** C#
#+BEGIN_SRC emacs-lisp
(use-package csharp-mode
:mode "\\.cs\\'")
#+END_SRC

545
init.el
View File

@ -31,176 +31,6 @@
(load "zim") (load "zim")
(load "window-manip") (load "window-manip")
(defun termux-p ()
"Check if Emacs is running under Termux."
(string-match-p
(regexp-quote "/com.termux/")
(expand-file-name "~")))
;; Whitespace mode
;;
;; It is turned on by default, and can be toggled with F10
(use-package whitespace
:demand
:config
(defun prevent-whitespace-mode-for-magit ()
(not (derived-mode-p 'magit-mode)))
(add-function :before-while whitespace-enable-predicate 'prevent-whitespace-mode-for-magit)
(global-whitespace-mode 1)
(setq whitespace-line-column 100)
:bind
(([f10] . whitespace-mode)
([(shift f10)] . global-whitespace-mode)
:map gpolonkai/pers-map
("w" . whitespace-cleanup)))
(use-package eshell
:config
(add-hook 'eshell-mode-hook
(lambda () (local-set-key (kbd "C-d") #'eshell-C-d)))
:bind
(:map gpolonkai/pers-map
("e" . eshell)))
;; Save place
(use-package saveplace
:config
(setq-default save-place t)
(setq save-place-file (expand-file-name ".places" user-emacs-directory)))
(defun gpolonkai/zone-enable ()
"Enable zoning out."
(interactive)
(zone-when-idle 60)
(message "I will zone out after idling for 60 seconds."))
(use-package zone
:demand
:config
(zone-when-idle 60)
:bind
(:map gpolonkai/pers-map
("zi" . gpolonkai/zone-enable)
("zq" . zone-leave-me-alone)))
(use-package origami
:demand
:config
(define-prefix-command 'origami-mode-map)
(define-key ctl-x-map (kbd "z") 'origami-mode-map)
(global-origami-mode)
:bind
(:map origami-mode-map
("o" . origami-open-node)
("O" . origami-open-node-recursively)
("c" . origami-close-node)
("C" . origami-close-node-recursively)
("a" . origami-toggle-node)
("A" . origami-recursively-toggle-node)
("R" . origami-open-all-nodes)
("M" . origami-close-all-nodes)
("v" . origami-show-only-node)
("k" . origami-previous-fold)
("j" . origami-forward-fold)
("x" . origami-reset)))
(use-package smartparens
:demand
:config
(show-smartparens-global-mode t)
(add-hook 'prog-mode-hook
'turn-on-smartparens-strict-mode)
(add-hook 'markdown-mode-hook
'turn-on-smartparens-strict-mode)
:bind
(([f9] . smartparens-strict-mode)
("C-c s u" . sp-unwrap-sexp)
("C-c s k" . sp-kill-sexp)))
(use-package smart-mode-line
:after
org
:config
(add-to-list 'sml/replacer-regexp-list
'("^~/Projects/" ":Proj:")
t)
(add-to-list 'sml/replacer-regexp-list
'("^~/Projektek/" ":Proj:")
t)
(add-to-list 'sml/replacer-regexp-list
(list (concat "^" (regexp-quote user-documents-directory))
":Doc:")
t)
(add-to-list 'sml/replacer-regexp-list
'("^:Proj:jekyll/gergelypolonkai.github.io/" ":Blog:")
t)
(add-to-list 'sml/replacer-regexp-list
(list "^:Proj:python/" ":Proj:Py:")
t)
(sml/setup)
(require 'cl-lib)
(setq-default header-line-format
'(""
mode-line-mule-info
mode-line-client
mode-line-modified
mode-line-remote
mode-line-frame-identification
mode-line-buffer-identification
sml/pos-id-separator
(vc-mode vc-mode)
mode-line-position))
(delete '(vc-mode vc-mode) mode-line-format)
(delete 'mode-line-frame-identification mode-line-format)
(delete 'mode-line-buffer-identification mode-line-format)
(delete 'mode-line-position mode-line-format)
(delete 'mode-line-mule-info mode-line-format)
(delete 'mode-line-modified mode-line-format)
(delete 'mode-line-client mode-line-format)
(delete 'mode-line-remote mode-line-format)
;; Add sml/pre-id-separator after mode-line-front-space
(let* ((front-space-position (1+ (cl-position 'mode-line-front-space mode-line-format)))
(mode-line-rest (nthcdr front-space-position mode-line-format))
(mode-line-beg (cl-subseq mode-line-format 0 front-space-position)))
(setq-default mode-line-format (nconc mode-line-beg
(list sml/pre-id-separator)
mode-line-rest))))
(use-package company
:config
(setq company-idle-delay nil
company-frontends '(company-pseudo-tooltip-frontend
company-echo-metadata-frontend)
company-dabbrev-downcase nil)
(put 'company-clang-arguments 'safe-local-variable #'nil-or-list-of-strings-p)
(global-company-mode))
(use-package projectile
:pin melpa-stable
:config
(projectile-global-mode t))
(use-package drag-stuff
:config
(drag-stuff-global-mode t)
(drag-stuff-define-keys))
;; Git gutter
;; If we are in text-only mode, there is no fringe.
(let ((gitgutter-package
(if (display-graphic-p)
"git-gutter-fringe"
"git-gutter")))
(eval `(use-package ,gitgutter-package
:demand
:config
(global-git-gutter-mode t)
:bind
(:map gpolonkai/pers-map
("gg" . git-gutter:update-all-windows)
("gn" . git-gutter:next-hunk)
("gp" . git-gutter:previous-hunk)))))
;; From gmane.emacs.orgmode ;; From gmane.emacs.orgmode
;; (http://article.gmane.org/gmane.emacs.orgmode/75222) ;; (http://article.gmane.org/gmane.emacs.orgmode/75222)
(defun f-ediff-org-showhide (buf command &rest cmdargs) (defun f-ediff-org-showhide (buf command &rest cmdargs)
@ -223,83 +53,6 @@
(f-ediff-org-showhide ediff-buffer-B 'hide-sublevels 1) (f-ediff-org-showhide ediff-buffer-B 'hide-sublevels 1)
(f-ediff-org-showhide ediff-buffer-C 'hide-sublevels 1)) (f-ediff-org-showhide ediff-buffer-C 'hide-sublevels 1))
;; Org mode
(use-package org
:demand
:init
(require 'xdg-paths)
(setq-default org-crypt-key "B0740C4C"
org-default-notes-file (concat user-documents-directory
(convert-standard-filename
"/orgmode/notes.org"))
org-directory (concat user-documents-directory
(convert-standard-filename "/orgmode/"))
org-agenda-files (concat user-documents-directory
(convert-standard-filename
"/orgmode/agenda_files"))
org-ellipsis "…#"
org-startup-folded 'content
org-mobile-directory (concat user-documents-directory
(convert-standard-filename
"/orgmode/mobile/"))
org-mobile-inbox-for-pull (concat
user-documents-directory
(convert-standard-filename
"/orgmode/from-mobile.org"))
org-log-done 'time
org-src-preserve-indentation t
org-log-into-drawer t
org-tags-column 0
org-startup-indented t
org-special-ctrl-a/e t)
:config
(require 'ox-md)
(unless (boundp 'org-capture-templates)
(setq org-capture-templates nil))
(add-to-list 'org-capture-templates
'("p" "Blog post"
entry (file+olp+datetree (concat org-directory "blog.org"))
"* %^{Title} :blog:\n :PROPERTIES:\n :on: %T\n :END:\n %i%?"))
(add-to-list 'org-capture-templates
'("g" "GT2 note"
entry (file+headline (concat org-directory "gt2-notes.org")
"Captures")
"** %^{Title}\n :PROPERTIES:\n :on: %T\n :END:\n %i%?"))
(setq org-time-stamp-formats '("<%Y-%m-%d>" . "<%Y-%m-%d %H:%M>")
org-todo-keywords '((sequence "TODO(t)"
"DOING(w@/!)"
"BLOCKED(b@/!)"
"|"
"CANCELED(c@/!)"
"REVIEW(r@/!)"
"DONE(d@/!)"))
org-goto-interface 'outline-path-completion
org-goto-max-level 10
org-html-checkbox-type 'unicode
org-html-checkbox-types
'((unicode (on . "<span class=\"task-done\">☑</span>")
(off . "<span class=\"task-todo\">☐</span>")
(trans . "<span class=\"task-in-progress\">▣</span>")))
org-src-window-setup 'current-window)
(add-hook 'ediff-select-hook 'f-ediff-org-unfold-tree-element)
(add-hook 'ediff-unselect-hook 'f-ediff-org-fold-tree)
:bind
(:map gpolonkai/pers-map
("a" . org-agenda-list)
("c" . org-capture)
("l" . org-store-link)
:map org-mode-map
("SPC" . org-space-key)
("C-c l" . org-toggle-link-display)
("C-a" . gpolonkai/move-to-beginning-of-line)
("C-e" . gpolonkai/move-to-end-of-line)))
(use-package org-bullets
:init
(add-hook 'org-mode-hook
(lambda ()
(if (display-graphic-p) org-bullets-mode))))
;; Waka-waka ;; Waka-waka
(use-package wakatime-mode (use-package wakatime-mode
:init :init
@ -307,112 +60,14 @@
:config :config
(global-wakatime-mode t)) (global-wakatime-mode t))
(use-package ace-window
:config
(setq aw-background nil
aw-dispatch-always t)
(add-to-list 'aw-dispatch-alist
'(?s gpolonkai/scroll-window-up " Scroll window up")
t)
(add-to-list 'aw-dispatch-alist
'(?S gpolonkai/scroll-window-down " Scroll window down")
t)
(add-to-list 'aw-dispatch-alist
'(?q gpolonkai/bury-window " Bury (quit) window")
t)
:bind
(:map ctl-x-map
("o" . ace-window)))
(use-package avy
:demand
:config
(avy-setup-default)
:bind
(("M-g c" . avy-goto-char)
("C-'" . avy-goto-char-2)
("M-g f" . avy-goto-line)
("M-g w" . avy-goto-word-1)
("M-g e" . avy-goto-word-0)))
(use-package focus
:bind
(([f8] . focus-mode)))
(use-package command-log-mode)
(use-package company-c-headers)
(use-package company-shell)
(use-package electric-case
:config
(add-hook 'c-mode-hook 'electric-case-c-init))
(use-package electric-operator
:config
(add-hook 'c-mode-common-hook 'electric-operator-mode)
;; Apply electric-operator-mode to vala-mode, too
(apply #'electric-operator-add-rules-for-mode 'vala-mode
electric-operator-prog-mode-rules))
(use-package emamux)
(use-package flycheck
:config
(global-flycheck-mode))
(use-package flycheck-pkg-config)
(use-package git-messenger
:bind
(:map gpolonkai/pers-map
("gm" . git-messenger:popup-message)))
(use-package git-timemachine
:bind
(([f6] . git-timemachine-toggle)))
(use-package gnugo) (use-package gnugo)
(use-package gobgen) (use-package gobgen)
(use-package goto-last-change
:bind
(("M-g /" . goto-last-change)))
(use-package id-manager
:config
(setq idm-database-file (expand-file-name "idm-db.gpg" user-emacs-directory))
:bind
(:map gpolonkai/pers-map
("i" . idm-open-list-command)))
(use-package identica-mode) (use-package identica-mode)
(use-package org-projectile)
(use-package smart-mode-line-powerline-theme
:init
(setq-default sml/theme 'powerline))
(use-package spinner)
(use-package sx
:demand
:bind
(:map gpolonkai/pers-map
("qi" . sx-inbox)
("qs" . sx-search)))
(use-package xlicense) (use-package xlicense)
(use-package ediff
:init
(setq-default ediff-merge-split-window-function 'split-window-horizontally
ediff-split-window-function 'split-window-vertically
ediff-window-setup-function 'ediff-setup-windows-plain))
(use-package plantuml-mode (use-package plantuml-mode
:init :init
(setq plantuml-jar-path (setq plantuml-jar-path
@ -430,39 +85,10 @@
'org-babel-load-languages 'org-babel-load-languages
'((plantuml . t)))) '((plantuml . t))))
(use-package org-random-todo
:demand
:config
;; Dont bug me too often…
(setq org-random-todo-how-often 3600)
:bind
(:map gpolonkai/pers-map
("r" . org-random-todo)))
(use-package yasnippet
:demand
:config
(yas-global-mode 1)
(add-hook 'post-command-hook 'sachachua/change-cursor-color-when-can-expand))
(use-package yasnippet-snippets)
(use-package vala-snippets
:after
yasnippet)
(use-package hungarian-holidays (use-package hungarian-holidays
:config :config
(hungarian-holidays-add)) (hungarian-holidays-add))
(use-package beacon
:demand
:config
(beacon-mode 1)
:bind
(:map gpolonkai/pers-map
("b" . beacon-blink)))
(use-package flyspell (use-package flyspell
:config :config
(add-hook 'prog-mode-hook (add-hook 'prog-mode-hook
@ -470,38 +96,10 @@
(add-hook 'text-mode-hook (add-hook 'text-mode-hook
'flyspell-mode)) 'flyspell-mode))
(use-package autorevert
:config
(global-auto-revert-mode 1))
(use-package rainbow-delimiters
:config
(add-hook 'prog-mode-hook
#'rainbow-delimiters-mode))
(use-package rainbow-mode
:config
(add-hook 'css-mode-hook 'rainbow-mode)
(add-hook 'scss-mode-hook 'rainbow-mode)
(add-hook 'sass-mode 'rainbow-mode))
(use-package hungry-delete (use-package hungry-delete
:config :config
(global-hungry-delete-mode)) (global-hungry-delete-mode))
(use-package eww
:config
(setq eww-search-prefix "https://www.google.com/?q="))
(use-package electric
:config
;; This seems to be the default, but lets make sure…
(electric-indent-mode 1))
(use-package restclient)
(use-package company-restclient)
(use-package alert (use-package alert
:config :config
(setq alert-default-style (setq alert-default-style
@ -561,101 +159,18 @@ INFO plist."
(use-package cheatsheet) (use-package cheatsheet)
(use-package savehist
:config
(savehist-mode 1))
;; Before this can be used, make sure the Symbola font is installed:
;; https://zhm.github.io/symbola/
(defun --set-emoji-font (frame)
"Adjust the font setting of FRAME so Emacs can display Emoji properly."
(when (fboundp 'set-fontset-font)
(if (eq system-type 'darwin)
;; For NS/Cocoa
(set-fontset-font t 'symbol
(font-spec :family "Apple Color Emoji")
frame 'prepend)
;; For Linux
(set-fontset-font t 'symbol
(font-spec :family "Symbola")
frame 'prepend))))
(use-package company-emoji
:after
company
:init
(--set-emoji-font nil)
:config
(add-to-list 'company-backends 'company-emoji)
(add-hook 'after-make-frame-functions
'--set-emoji-font))
(use-package zygospore
:bind
(:map ctl-x-map
("1" . zygospore-toggle-delete-other-windows)))
(use-package webjump
:bind
(:map gpolonkai/pers-map
("j" . webjump)))
(use-package which-func
:config
(add-hook 'prog-mode-hook
(lambda ()
(if (fboundp 'which-function-mode)
(which-function-mode)
(which-func-mode))))
(setq which-func-unknown ""))
(use-package ace-popup-menu (use-package ace-popup-menu
:config :config
(ace-popup-menu-mode 1)) (ace-popup-menu-mode 1))
(use-package bind-key)
(use-package kanban)
(use-package achievements (use-package achievements
:config :config
(achievements-mode 1)) (achievements-mode 1))
(use-package auto-highlight-symbol
:config
(global-auto-highlight-symbol-mode t))
(use-package auto-package-update
:config
(setq auto-package-update-interval 7
auto-package-update-delete-old-versions t)
;; Lets do this in after-init-hook, as use-package invocations may modify
;; the list of installed packages
(add-hook 'after-init-hook 'auto-package-update-maybe))
(use-package cookie1
:demand t
:config
(setq cookie-file (concat user-emacs-directory "fortune-cookies.txt"))
:bind
(:map gpolonkai/pers-map
("k" . cookie)))
(use-package ace-mc)
(use-package dired-k
:bind
(:map dired-mode-map
("K" . dired-k)))
(use-package form-feed (use-package form-feed
:config :config
(add-hook 'emacs-lisp-mode-hook 'form-feed-mode)) (add-hook 'emacs-lisp-mode-hook 'form-feed-mode))
(use-package anzu
:config
(global-anzu-mode 1))
(use-package auto-virtualenv (use-package auto-virtualenv
:config :config
(add-hook 'python-mode-hook 'auto-virtualenv-set-virtualenv) (add-hook 'python-mode-hook 'auto-virtualenv-set-virtualenv)
@ -666,73 +181,13 @@ INFO plist."
(use-package hl-todo) (use-package hl-todo)
(use-package glasses
:config
(add-hook 'prog-mode-hook 'glasses-mode))
(when (display-graphic-p)
(use-package eshell-fringe-status
:config
(add-hook 'eshell-mode-hook 'eshell-fringe-status-mode)))
(use-package eshell-prompt-extras
:config
(with-eval-after-load "esh-opt"
(autoload 'epe-theme-lambda "eshell-prompt-extras")
(setq eshell-highlight-prompt nil
eshell-prompt-function 'epe-theme-lambda)))
(use-package expand-region
:bind
(("C-@" . er/expand-region)))
(use-package anaconda-mode (use-package anaconda-mode
:config :config
(add-hook 'python-mode-hook 'anaconda-mode) (add-hook 'python-mode-hook 'anaconda-mode)
(add-hook 'python-mode-hook 'anaconda-eldoc-mode)) (add-hook 'python-mode-hook 'anaconda-eldoc-mode))
(use-package company-anaconda
:after
company
:config
(add-to-list 'company-backends 'company-anaconda))
(use-package mediawiki
:after
id-manager
:config
(add-to-list 'mediawiki-site-alist
'("WikEmacs"
"http://wikemacs.org/wiki/"
(gpolonkai/idm-get-id-for-account "WikEmacs")
(gpolonkai/idm-get-password-for-account "WikEmacs"))))
(use-package github-notifier
:after
id-manager
:config
(setq github-notifier-token (gpolonkai/idm-get-password-for-account "GitHub"))
(github-notifier-mode))
(use-package gist)
(use-package company-web
:config
(require 'company-web-html))
(use-package enlive) (use-package enlive)
(use-package po-mode)
(use-package dashboard
:after
projectile
:config
(add-to-list 'dashboard-items '(projects . 5) t)
(dashboard-setup-startup-hook))
(use-package csharp-mode)
(use-package emmet-mode (use-package emmet-mode
:config :config
(setq emmet-self-closing-tag-style "") (setq emmet-self-closing-tag-style "")