Move everything else to the Org config

This commit is contained in:
Gergely Polonkai 2018-07-30 21:14:51 +02:00
parent 50ec5643de
commit b6a6bd938a
2 changed files with 671 additions and 455 deletions

View File

@ -765,6 +765,117 @@ Copied from https://ryuslash.org/posts/C-d-to-close-eshell.html
"Creation-Date: " (zim-timestamp) "\n\n")))) "Creation-Date: " (zim-timestamp) "\n\n"))))
#+END_SRC #+END_SRC
** Utility functions for EDiff
EDiff and Org-mode files dont play nice together
From [[http://article.gmane.org/gmane.emacs.orgmode/75222][gmane.emacs.orgmode]]
#+BEGIN_SRC emacs-lisp
(defun f-ediff-org-showhide (buf command &rest cmdargs)
"If buffer BUF exists and in `org-mode', execute COMMAND with CMDARGS."
(when buf
(when (eq (buffer-local-value 'major-mode (get-buffer buf)) 'org-mode)
(save-excursion
(set-buffer buf)
(apply command cmdargs)))))
(defun f-ediff-org-unfold-tree-element ()
"Unfold tree at diff location."
(f-ediff-org-showhide ediff-buffer-A 'org-reveal)
(f-ediff-org-showhide ediff-buffer-B 'org-reveal)
(f-ediff-org-showhide ediff-buffer-C 'org-reveal))
(defun f-ediff-org-fold-tree ()
"Fold tree back to top level."
(f-ediff-org-showhide ediff-buffer-A 'hide-sublevels 1)
(f-ediff-org-showhide ediff-buffer-B 'hide-sublevels 1)
(f-ediff-org-showhide ediff-buffer-C 'hide-sublevels 1))
#+END_SRC
** Leave ~isearch~ at the other end of the matched string
Taken from [[http://endlessparentheses.com/leave-the-cursor-at-start-of-match-after-isearch.html][endless parentheses]]
#+BEGIN_SRC emacs-lisp
(defun isearch-exit-other-end ()
"Exit isearch, at the opposite end of the string."
(interactive)
(isearch-exit)
(goto-char isearch-other-end))
#+END_SRC
** Mark the current match after leaving ~isearch~
Taken from [[http://emacs.stackexchange.com/a/31321/507][here]].
#+BEGIN_SRC emacs-lisp
(defun isearch-exit-mark-match ()
"Exit isearch and mark the current match."
(interactive)
(isearch-exit)
(push-mark isearch-other-end)
(activate-mark))
#+END_SRC
** Make the slash (~/~) key act like ~C-j~ in some Helm views
#+BEGIN_SRC emacs-lisp
(defun gpolonkai/helm-ff-slash-dir-complete ()
"Make forward slash (/) do completion in helm."
(interactive)
(if (and (or
(equal "magit-status" (assoc-default 'name (helm-get-current-source)))
(equal "Find Files" (assoc-default 'name (helm-get-current-source))))
(stringp (helm-get-selection))
(file-directory-p (helm-get-selection)))
(helm-execute-persistent-action)
(insert "/")))
#+END_SRC
** Turn the cursor to purple if Yasnippets TAB function would fire
Taken from [[http://pages.sachachua.com/.emacs.d/Sacha.html][Sacha Chuas config]].
#+BEGIN_SRC emacs-lisp
;; TODO: 'cursor-color is sometimes nil, but why?
(setq default-cursor-color (or (frame-parameter nil 'cursor-color) "#ffd85c"))
(setq yasnippet-can-fire-cursor-color "purple")
;; It will test whether it can expand, if yes, cursor color -> purple.
(defun yasnippet-can-fire-p (&optional field)
"Check if the word before point can be expanded with yasnippet.
TODO: What is FIELD for?"
(interactive)
(setq yas--condition-cache-timestamp (current-time))
(let (templates-and-pos)
(unless (and yas-expand-only-for-last-commands
(not (member last-command yas-expand-only-for-last-commands)))
(setq templates-and-pos (if field
(save-restriction
(narrow-to-region (yas--field-start field)
(yas--field-end field))
(yas--templates-for-key-at-point))
(yas--templates-for-key-at-point))))
(and templates-and-pos (first templates-and-pos))))
(defun sachachua/change-cursor-color-when-can-expand (&optional field)
"Change cursor color if the text before point can be expanded with yasnippet.
TODO: What is FIELD for?"
(interactive)
(when (eq last-command 'self-insert-command)
(set-cursor-color (if (sachachua/can-expand)
yasnippet-can-fire-cursor-color
default-cursor-color))))
(defun sachachua/can-expand ()
"Return t if right after an expandable thing."
(or (abbrev--before-point) (yasnippet-can-fire-p)))
#+END_SRC
* UI preferences * UI preferences
** Tweak window chrome ** Tweak window chrome
@ -815,6 +926,64 @@ Because we can.
(global-prettify-symbols-mode t) (global-prettify-symbols-mode t)
#+END_SRC #+END_SRC
And set up all the pretty symbols.
#+BEGIN_SRC emacs-lisp
;; Add some symbols to be prettified
(setq prettify-symbols-alist
'(("lambda" . 955) ; λ
("function" . 402) ; ƒ
("->" . 8594) ; →
("=>" . 8658) ; ⇒
("map" . 8614) ; ↦
("not" . 172)) ; ¬
;; …and some pairs to complete
;; TODO: maybe add-to-list is a better way to do it
insert-pair-alist '(
(40 41) ; ()
(91 93) ; []
(123 125) ; {}
(60 62) ; <>
(34 34) ; ""
(39 39) ; ''
(96 39) ; `'
(8220 8221) ; “”
(8222 8221) ; „”
(8216 8217) ;
(8249 8250) ;
(8250 8249) ;
(171 187) ; «»
(187 171)) ; »«
;; Set the frame title to the current file name
frame-title-format '((:eval (concat system-name
": "
(if (buffer-file-name)
(abbreviate-file-name
(buffer-file-name))
"%b")))))
#+END_SRC
** Treat soft line breaks as hard ones in textual modes
#+BEGIN_SRC emacs-lisp
;; text-mode settings
(add-hook 'text-mode-hook (lambda () (visual-line-mode t)))
#+END_SRC
* Enable disabled commands
Because Im a rock star like that.
#+BEGIN_SRC emacs-lisp
(put 'downcase-region 'disabled nil)
(put 'upcase-region 'disabled nil)
(put 'erase-buffer 'disabled nil)
(put 'narrow-to-region 'disabled nil)
(put 'set-goal-column 'disabled nil)
#+END_SRC
* Load some built-in libraries * Load some built-in libraries
** ~thingatpt~ ** ~thingatpt~
@ -839,6 +1008,15 @@ Because we can.
calendar-daylight-time-zone-name "CEST")) calendar-daylight-time-zone-name "CEST"))
#+END_SRC #+END_SRC
*** Add the SysAdmin day to the calendar
Because Im a sysadmin, too.
#+BEGIN_SRC emacs-lisp
(add-to-list 'holiday-other-holidays '(holiday-float 7 5 -1 "SysAdmin Day") t)
(add-to-list 'holiday-other-holidays '(holiday-fixed 10 21 "Reptile Awareness Day") t)
#+END_SRC
** nXML ** nXML
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
@ -1012,6 +1190,49 @@ The cookies are from the Hungarian version an ancient MS-DOS based program calle
("k" . cookie))) ("k" . cookie)))
#+END_SRC #+END_SRC
** News reader
#+BEGIN_SRC emacs-lisp
(use-package newsticker
:demand
:config
(setq newsticker-url-list '(("(or emacs irrelevant)"
"http://oremacs.com/atom.xml"
nil nil nil)
("think"
"http://batsov.com/atom.xml"
nil nil nil)
("Endless Parentheses"
"http://endlessparentheses.com/atom.xml"
nil nil nil)
("Irreal"
"http://irreal.org/blog/?feed=rss2"
nil nil nil)
;; The followint may supersede previous entries
("Planet Emacs"
"http://planet.emacsen.org/atom.xml"
nil nil nil)))
:bind
(:map gpolonkai/pers-map
("n" . newsticker-show-news)))
#+END_SRC
** Browse URL functionality in Termux
#+BEGIN_SRC emacs-lisp
(when (termux-p)
(use-package browse-url
:ensure nil
:config
(advice-add 'browse-url-default-browser :override
(lambda (url &rest args)
(start-process-shell-command
"open-url"
nil
(concat "am start -a android.intent.action.VIEW --user 0 -d "
url))))))
#+END_SRC
* ~use-package~ packages * ~use-package~ packages
** Automatically upgrade packages every week ** Automatically upgrade packages every week
@ -1166,6 +1387,14 @@ Highlight point. Sometimes its not easy to see.
eshell-prompt-function 'epe-theme-lambda))) eshell-prompt-function 'epe-theme-lambda)))
#+END_SRC #+END_SRC
*** Show form feeds as a horizontal line
#+BEGIN_SRC emacs-lisp
(use-package form-feed
:config
(add-hook 'emacs-lisp-mode-hook 'form-feed-mode))
#+END_SRC
** Highlight the current line ** Highlight the current line
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
@ -1226,6 +1455,16 @@ Because one is never enough.
("d" . mc/mark-all-like-this-in-defun))) ("d" . mc/mark-all-like-this-in-defun)))
#+END_SRC #+END_SRC
*** Incremental search for multiple cursors
#+BEGIN_SRC emacs-lisp
(use-package phi-search)
(use-package phi-search-mc
:config
(phi-search-mc/setup-keys))
#+END_SRC
*** Some extras *** Some extras
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
@ -1524,6 +1763,161 @@ Toggle other windows for maximum focus. When focus is no longer needed, they ca
(dashboard-setup-startup-hook)) (dashboard-setup-startup-hook))
#+END_SRC #+END_SRC
** Hungarian holidays in the Calendar
#+BEGIN_SRC emacs-lisp
(use-package hungarian-holidays
:config
(hungarian-holidays-add))
#+END_SRC
** FlySpell
For all your spell-checking needs.
#+BEGIN_SRC emacs-lisp
(use-package flyspell
:config
(add-hook 'prog-mode-hook
'flyspell-prog-mode)
(add-hook 'text-mode-hook
'flyspell-mode))
#+END_SRC
** Delete all the whitespace
#+BEGIN_SRC emacs-lisp
(use-package hungry-delete
:config
(global-hungry-delete-mode))
#+END_SRC
** Send alerts to a notification system
#+BEGIN_SRC emacs-lisp
(use-package alert
:config
(setq alert-default-style
(if (termux-p)
(progn
;; TODO Remove this as soon as my PR gets merged
;; https://github.com/jwiegley/alert/pull/41
(unless (fboundp 'alert-termux-notify)
(defcustom alert-termux-command (executable-find "termux-notification")
"Path to the termux-notification command.
This is found in the termux-api package, and it requires the Termux
API addon app to be installed."
:type 'file
:group 'alert)
(defun alert-termux-notify (info)
"Send INFO using termux-notification.
Handles :TITLE and :MESSAGE keywords from the
INFO plist."
(if alert-termux-command
(let ((args (nconc
(when (plist-get info :title)
(list "-t" (alert-encode-string (plist-get info :title))))
(list "-c" (alert-encode-string (plist-get info :message))))))
(apply #'call-process alert-termux-command nil
(list (get-buffer-create " *termux-notification output*") t)
nil args))
(alert-message-notify info)))
(alert-define-style 'termux :title "Notify using termux"
:notifier #'alert-termux-notify))
'termux)
'libnotify)))
#+END_SRC
** Replace the GUI popup menu with something more efficient
#+BEGIN_SRC emacs-lisp
(use-package ace-popup-menu
:config
(ace-popup-menu-mode 1))
#+END_SRC
** Im an achiever!
#+BEGIN_SRC emacs-lisp
(use-package achievements
:config
(achievements-mode 1))
#+END_SRC
** Secretaria
Because even secretaries need a secretary today.
#+BEGIN_SRC emacs-lisp
(use-package secretaria
:after
alert
:config
;; use this for getting a reminder every 30 minutes of those tasks
;; scheduled for today and which have no time of day defined.
(add-hook 'after-init-hook
#'secretaria-today-unknown-time-appt-always-remind-me))
#+END_SRC
** The Silver Searcher
#+BEGIN_SRC emacs-lisp
(use-package ag
:after projectile
:bind
(:map projectile-mode-map
("C-c p C-a" . ag-project)))
#+END_SRC
** A fancier ~narrow-mode~
#+BEGIN_SRC emacs-lisp
(use-package fancy-narrow
:config
(fancy-narrow-mode))
#+END_SRC
** Undo tree
#+BEGIN_SRC emacs-lisp
(use-package undo-tree)
#+END_SRC
** All the icons!
Should the fonts be missing, run ~(all-the-icons-install-fonts)~. Its not run automatically, as it
requires connecting to a website and download a pretty large font file.
#+BEGIN_SRC emacs-lisp
(use-package all-the-icons)
#+END_SRC
** NeoTree, if Dired is not an option
#+BEGIN_SRC emacs-lisp
(use-package neotree
:after
all-the-icons
:config
(setq neo-theme (if (display-graphic-p) 'icons 'arrow))
:bind
(([f5] . neotree-toggle)))
#+END_SRC
** Waka-waka
This will be replaced with something self-hosted, eventually.
#+BEGIN_SRC emacs-lisp
(use-package wakatime-mode
:init
(setq-default wakatime-cli-path (executable-find "wakatime"))
:config
(global-wakatime-mode t))
#+END_SRC
* Make programming a bit easier * Make programming a bit easier
** Electric case ** Electric case
@ -1607,6 +2001,154 @@ A big help during refactoring.
(add-hook 'prog-mode-hook 'glasses-mode)) (add-hook 'prog-mode-hook 'glasses-mode))
#+END_SRC #+END_SRC
** GObject boilerplate generator
#+BEGIN_SRC emacs-lisp
(use-package gobgen)
#+END_SRC
** Insert specific licenses in the current buffer
#+BEGIN_SRC emacs-lisp
(use-package xlicense
:bind
(:map gpolonkai/pers-map
("L" . insert-license)))
#+END_SRC
** Highlight TODO, FIXME, and XXX
#+BEGIN_SRC emacs-lisp
(use-package hl-todo)
#+END_SRC
* Python related setup and ~use-package~ calls
Because, well, thats my job now. Of course it gets a dedicated section.
** Set up pretty symbols for Python
Because they are fancy.
- not: ¬
- in: ∈
- def: ƒ
Maybe add ∉ for ~not in~ later, if possible.
#+BEGIN_SRC emacs-lisp
(add-hook 'python-mode-hook
(lambda ()
(add-to-list 'prettify-symbols-alist
'("not" . 172))
(add-to-list 'prettify-symbols-alist
'("in" . 8712))
(add-to-list 'prettify-symbols-alist
'("def" . 402))))
#+END_SRC
** Automatically load the virtualenv if there is one
#+BEGIN_SRC emacs-lisp
(use-package auto-virtualenv
:config
(add-hook 'python-mode-hook 'auto-virtualenv-set-virtualenv)
(add-hook 'projectile-after-switch-project-hook
'auto-virtualenv-set-virtualenv))
#+END_SRC
** Anaconda mode
#+BEGIN_SRC emacs-lisp
(use-package anaconda-mode
:config
(add-hook 'python-mode-hook 'anaconda-mode)
(add-hook 'python-mode-hook 'anaconda-eldoc-mode))
#+END_SRC
* C mode
Because thats still my favourite language.
** Set up my own C style
#+BEGIN_SRC emacs-lisp
(defconst my-c-style
'((c-tab-always-indent . t)
(c-comment-only-line-offset . 4)
(c-hanging-braces-alist . ((substatement-open after)
(brace-list-open)))
(c-hanging-colons-alist . ((member-init-intro before)
(inher-intro)
(case-label after)
(label after)
(access-label after)))
(c-cleanup-list . (scope-operator
empty-defun-braces
defun-close-semi))
(c-offsets-alist . ((arglist-close . +)
(arglist-intro . +)
(substatement-open . 0)
(case-label . 4)
(block-open . 0)
(knr-argdecl-intro . -)
(comment-intro . 0)
(member-init-intro . ++)))
(c-echo-syntactic-information-p . t))
"My C Programming Style.")
(c-add-style "PERSONAL" my-c-style)
#+END_SRC
** Some common initialisation for C mode
#+BEGIN_SRC emacs-lisp
(add-hook 'c-mode-common-hook
(lambda ()
(local-set-key (kbd "C-c o") 'ff-find-other-file)
(c-set-style "PERSONAL")
(setq tab-width 4
indent-tabs-mode nil)
(c-toggle-auto-newline 1)))
(add-hook 'c-initialization-hook
(lambda ()
(define-key c-mode-base-map (kbd "C-m") 'c-context-line-break)))
#+END_SRC
** Set indentation levels to the same as the tab width
#+BEGIN_SRC emacs-lisp
(defvaralias 'c-basic-offset 'tab-width)
(defvaralias 'cperl-indent-level 'tab-width)
#+END_SRC
* Web development
** Web mode
#+BEGIN_SRC emacs-lisp
(use-package web-mode
:mode "\\.html?\\'"
:config
(setq web-mode-enable-auto-indentation nil)
(setq web-mode-enable-engine-detection t))
#+END_SRC
** Emmet mode
#+BEGIN_SRC emacs-lisp
(use-package emmet-mode
:config
(setq emmet-self-closing-tag-style "")
(add-hook 'web-mode 'emmet-mode)
(add-hook 'css-mode 'emmet-mode))
#+END_SRC
** Query HTML tags by CSS selectors
#+BEGIN_SRC emacs-lisp
(use-package enlive)
#+END_SRC
* FlyCheck * FlyCheck
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
@ -1722,6 +2264,37 @@ To display fancy bullets in graphics mode.
("r" . org-random-todo))) ("r" . org-random-todo)))
#+END_SRC #+END_SRC
** Citations and cross-references for Org
#+BEGIN_SRC emacs-lisp
(use-package org-ref
:after
org
:config
(setq org-ref-bibliography-notes (concat user-documents-directory
(convert-standard-filename
"/orgmode/bibliography-notes"))
org-ref-default-bibliography '((concat user-documents-directory
(convert-standard-filename
"/orgmode/references.bib")))
org-ref-pdf-directory (concat user-documents-directory
(convert-standard-filename
"/orgmode/bibtex-pdfs"))))
#+END_SRC
And set up a function to open PDF files with the system pdf viewer, using ~xdg-open~.
An alternative could be
#+BEGIN_EXAMPLE
(setq bibtex-completion-pdf-open-function 'org-open-file))
#+END_EXAMPLE
#+BEGIN_SRC emacs-lisp
(setq bibtex-completion-pdf-open-function
(lambda (fpath)
(start-process "xdg-open" "*open*" "open" fpath)))
#+END_SRC
* Git & Co. * Git & Co.
** Git status on the fringe ** Git status on the fringe
@ -2078,16 +2651,6 @@ See previous versions of the current file.
:mode "\\.vala\\'") :mode "\\.vala\\'")
#+END_SRC #+END_SRC
** Web
#+BEGIN_SRC emacs-lisp
(use-package web-mode
:mode "\\.html?\\'"
:config
(setq web-mode-enable-auto-indentation nil)
(setq web-mode-enable-engine-detection t))
#+END_SRC
** Dockerfile ** Dockerfile
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
@ -2119,3 +2682,101 @@ See previous versions of the current file.
(use-package csharp-mode (use-package csharp-mode
:mode "\\.cs\\'") :mode "\\.cs\\'")
#+END_SRC #+END_SRC
** Gherkin (BDD) feature files
#+BEGIN_SRC emacs-lisp
(use-package feature-mode
:mode "\\.feature\\'")
#+END_SRC
** PlantUML
Before using this, make sure the latest PlantUML JAR file is downloaded into the downloads
directory. It is available from [[http://plantuml.com/download][here]].
#+BEGIN_SRC emacs-lisp
(use-package plantuml-mode
:init
(setq plantuml-jar-path
(expand-file-name
;; Make sure we have a download location even if XDG is not working
(cond
((xdg-user-dir "DOWNLOAD")
(concat (xdg-user-dir "DOWNLOAD") "/plantuml.jar"))
(t
"~/Downloads/plantuml.jar"))))
(defvaralias 'org-plantuml-jar-path 'plantuml-jar-path)
:config
(org-babel-do-load-languages
'org-babel-load-languages
'((plantuml . t))))
#+END_SRC
* Games
** Gnu Go
#+BEGIN_SRC emacs-lisp
(use-package gnugo)
#+END_SRC
* Last, but not least, key bindings!
#+BEGIN_SRC emacs-lisp
;; Custom key bindings
(bind-keys
:map global-map
("M-(" . æ-enclose-region)
("<C-return>" . open-line-below)
("<C-S-return>" . open-line-above)
("M-t" . nil) ;; Remove the old keybinding
("M-t c" . transpose-chars)
("M-t w" . transpose-words)
("M-t l" . transpose-lines)
("M-t e" . transpose-sexps)
("M-t s" . transpose-sentences)
("M-t p" . transpose-paragraphs)
("M-t W" . transpose-windows)
("C-a" . gpolonkai/move-to-beginning-of-line)
("C-e" . gpolonkai/move-to-end-of-line)
("M-q" . sachachua/fill-or-unfill-paragraph)
("C-c r" . round-number-at-point-to-decimals)
("C-s" . isearch-forward-regexp)
("C-r" . isearch-backward-regexp)
("C-M-s" . isearch-forward)
("C-M-r" . isearch-backward)
("C-~" . toggle-char-case)
:map ctl-x-map
("C-y" . gpolonkai/duplicate-line)
("_" . maximize-window)
("C-r" . rename-current-buffer-file)
("C-d" . delete-current-buffer-file)
("|" . toggle-window-split)
("k" . gpolonkai/kill-this-buffer)
("M-c" . gpolonkai/kill-this-buffer-delete-this-window)
("M-k" . gpolonkai/undo-buffer-kill)
("C-b" . bury-buffer)
("/" . repeat)
:map isearch-mode-map
("<C-return>" . isearch-exit-other-end)
("<S-return>" . isearch-exit-mark-match)
:map gpolonkai/pers-map
("m" . hidden-mode-line-mode)
("C-i e" . "gergely@polonkai.eu")
("C-i w" . "http://gergely.polonkai.eu/")
("C-p" . package-list-packages)
("o i" . gpolonkai/visit-init-file)
("o o" . gpolonkai/visit-org-index)
("u" . browse-url-at-point)
("C" . clean-buffer-list))
#+END_SRC
** TODO These fail to work using ~bind-keys~, but why?
#+BEGIN_SRC emacs-lisp
(define-key 'help-command (kbd "C-l") 'find-library)
(define-key 'help-command (kbd "C-f") 'find-function)
(define-key 'help-command (kbd "C-k") 'find-function-on-key)
(define-key 'help-command (kbd "C-v") 'find-variable)
#+END_SRC

445
init.el
View File

@ -28,453 +28,8 @@
;; Load my own functions ;; Load my own functions
(load "gnu-c-header") (load "gnu-c-header")
;; From gmane.emacs.orgmode
;; (http://article.gmane.org/gmane.emacs.orgmode/75222)
(defun f-ediff-org-showhide (buf command &rest cmdargs)
"If buffer BUF exists and in `org-mode', execute COMMAND with CMDARGS."
(when buf
(when (eq (buffer-local-value 'major-mode (get-buffer buf)) 'org-mode)
(save-excursion
(set-buffer buf)
(apply command cmdargs)))))
(defun f-ediff-org-unfold-tree-element ()
"Unfold tree at diff location."
(f-ediff-org-showhide ediff-buffer-A 'org-reveal)
(f-ediff-org-showhide ediff-buffer-B 'org-reveal)
(f-ediff-org-showhide ediff-buffer-C 'org-reveal))
(defun f-ediff-org-fold-tree ()
"Fold tree back to top level."
(f-ediff-org-showhide ediff-buffer-A 'hide-sublevels 1)
(f-ediff-org-showhide ediff-buffer-B 'hide-sublevels 1)
(f-ediff-org-showhide ediff-buffer-C 'hide-sublevels 1))
;; Waka-waka
(use-package wakatime-mode
:init
(setq-default wakatime-cli-path (executable-find "wakatime"))
:config
(global-wakatime-mode t))
(use-package gnugo)
(use-package gobgen)
(use-package xlicense)
(use-package plantuml-mode
:init
(setq plantuml-jar-path
(expand-file-name
;; Make sure we have a download location even if XDG is not
;; working
(cond
((xdg-user-dir "DOWNLOAD")
(concat (xdg-user-dir "DOWNLOAD") "/plantuml.jar"))
(t
"~/Downloads/plantuml.jar"))))
(defvaralias 'org-plantuml-jar-path 'plantuml-jar-path)
:config
(org-babel-do-load-languages
'org-babel-load-languages
'((plantuml . t))))
(use-package hungarian-holidays
:config
(hungarian-holidays-add))
(use-package flyspell
:config
(add-hook 'prog-mode-hook
'flyspell-prog-mode)
(add-hook 'text-mode-hook
'flyspell-mode))
(use-package hungry-delete
:config
(global-hungry-delete-mode))
(use-package alert
:config
(setq alert-default-style
(if (termux-p)
(progn
;; TODO Remove this as soon as my PR gets merged
;; https://github.com/jwiegley/alert/pull/41
(unless (fboundp 'alert-termux-notify)
(defcustom alert-termux-command (executable-find "termux-notification")
"Path to the termux-notification command.
This is found in the termux-api package, and it requires the Termux
API addon app to be installed."
:type 'file
:group 'alert)
(defun alert-termux-notify (info)
"Send INFO using termux-notification.
Handles :TITLE and :MESSAGE keywords from the
INFO plist."
(if alert-termux-command
(let ((args (nconc
(when (plist-get info :title)
(list "-t" (alert-encode-string (plist-get info :title))))
(list "-c" (alert-encode-string (plist-get info :message))))))
(apply #'call-process alert-termux-command nil
(list (get-buffer-create " *termux-notification output*") t)
nil args))
(alert-message-notify info)))
(alert-define-style 'termux :title "Notify using termux"
:notifier #'alert-termux-notify))
'termux)
'libnotify)))
(use-package newsticker
:demand
:config
(setq newsticker-url-list '(("(or emacs irrelevant)"
"http://oremacs.com/atom.xml"
nil nil nil)
("think"
"http://batsov.com/atom.xml"
nil nil nil)
("Endless Parentheses"
"http://endlessparentheses.com/atom.xml"
nil nil nil)
("Irreal"
"http://irreal.org/blog/?feed=rss2"
nil nil nil)
;; The followint may supersede previous entries
("Planet Emacs"
"http://planet.emacsen.org/atom.xml"
nil nil nil)))
:bind
(:map gpolonkai/pers-map
("n" . newsticker-show-news)))
(use-package cheatsheet) (use-package cheatsheet)
(use-package ace-popup-menu
:config
(ace-popup-menu-mode 1))
(use-package achievements
:config
(achievements-mode 1))
(use-package form-feed
:config
(add-hook 'emacs-lisp-mode-hook 'form-feed-mode))
(use-package auto-virtualenv
:config
(add-hook 'python-mode-hook 'auto-virtualenv-set-virtualenv)
(add-hook 'projectile-after-switch-project-hook
'auto-virtualenv-set-virtualenv))
(use-package gitlab) (use-package gitlab)
(use-package hl-todo)
(use-package anaconda-mode
:config
(add-hook 'python-mode-hook 'anaconda-mode)
(add-hook 'python-mode-hook 'anaconda-eldoc-mode))
(use-package enlive)
(use-package emmet-mode
:config
(setq emmet-self-closing-tag-style "")
(add-hook 'web-mode 'emmet-mode)
(add-hook 'css-mode 'emmet-mode))
(use-package phi-search)
(use-package phi-search-mc
:config
(phi-search-mc/setup-keys))
(use-package secretaria
:after
alert
:config
;; use this for getting a reminder every 30 minutes of those tasks
;; scheduled for today and which have no time of day defined.
(add-hook 'after-init-hook
#'secretaria-today-unknown-time-appt-always-remind-me))
(when (termux-p)
(use-package browse-url
:ensure nil
:config
(advice-add 'browse-url-default-browser :override
(lambda (url &rest args)
(start-process-shell-command
"open-url"
nil
(concat "am start -a android.intent.action.VIEW --user 0 -d "
url))))))
(use-package feature-mode)
(use-package org-ref
:after
org
:config
(setq org-ref-bibliography-notes (concat user-documents-directory
(convert-standard-filename
"/orgmode/bibliography-notes"))
org-ref-default-bibliography '((concat user-documents-directory
(convert-standard-filename
"/orgmode/references.bib")))
org-ref-pdf-directory (concat user-documents-directory
(convert-standard-filename
"/orgmode/bibtex-pdfs"))))
(use-package ag
:after projectile
:bind
(:map projectile-mode-map
("C-c p C-a" . ag-project)))
(use-package fancy-narrow
:config
(fancy-narrow-mode))
(use-package undo-tree)
(use-package all-the-icons)
(use-package neotree
:after
all-the-icons
:config
(setq neo-theme (if (display-graphic-p) 'icons 'arrow))
:bind
(("<f5>" . neotree-toggle)))
;; open pdf with system pdf viewer (works on mac)
(setq bibtex-completion-pdf-open-function
(lambda (fpath)
(start-process "open" "*open*" "open" fpath)))
;; alternative
;; (setq bibtex-completion-pdf-open-function 'org-open-file))
(add-hook 'python-mode-hook
(lambda ()
(add-to-list 'prettify-symbols-alist
'("not" . 172))
(add-to-list 'prettify-symbols-alist
'("in" . 8712))
(add-to-list 'prettify-symbols-alist
'("def" . 402))))
;; `c-mode' settings
(add-hook 'c-mode-common-hook
(lambda ()
(local-set-key (kbd "C-c o") 'ff-find-other-file)
(c-set-style "PERSONAL")
(setq tab-width 4
indent-tabs-mode nil)
(c-toggle-auto-newline 1)))
(add-hook 'c-initialization-hook
(lambda ()
(define-key c-mode-base-map (kbd "C-m") 'c-context-line-break)))
(defvaralias 'c-basic-offset 'tab-width)
(defvaralias 'cperl-indent-level 'tab-width)
(defconst my-c-style
'((c-tab-always-indent . t)
(c-comment-only-line-offset . 4)
(c-hanging-braces-alist . ((substatement-open after)
(brace-list-open)))
(c-hanging-colons-alist . ((member-init-intro before)
(inher-intro)
(case-label after)
(label after)
(access-label after)))
(c-cleanup-list . (scope-operator
empty-defun-braces
defun-close-semi))
(c-offsets-alist . ((arglist-close . +)
(arglist-intro . +)
(substatement-open . 0)
(case-label . 4)
(block-open . 0)
(knr-argdecl-intro . -)
(comment-intro . 0)
(member-init-intro . ++)))
(c-echo-syntactic-information-p . t))
"My C Programming Style.")
(c-add-style "PERSONAL" my-c-style)
;; Custom key bindings
(bind-keys
:map global-map
("M-(" . æ-enclose-region)
("<C-return>" . open-line-below)
("<C-S-return>" . open-line-above)
("M-t" . nil) ;; Remove the old keybinding
("M-t c" . transpose-chars)
("M-t w" . transpose-words)
("M-t l" . transpose-lines)
("M-t e" . transpose-sexps)
("M-t s" . transpose-sentences)
("M-t p" . transpose-paragraphs)
("M-t W" . transpose-windows)
("C-a" . gpolonkai/move-to-beginning-of-line)
("C-e" . gpolonkai/move-to-end-of-line)
("M-q" . sachachua/fill-or-unfill-paragraph)
("C-c r" . round-number-at-point-to-decimals)
("C-s" . isearch-forward-regexp)
("C-r" . isearch-backward-regexp)
("C-M-s" . isearch-forward)
("C-M-r" . isearch-backward)
("C-~" . toggle-char-case)
:map ctl-x-map
("C-y" . gpolonkai/duplicate-line)
("_" . maximize-window)
("C-r" . rename-current-buffer-file)
("C-d" . delete-current-buffer-file)
("|" . toggle-window-split)
("k" . gpolonkai/kill-this-buffer)
("M-c" . gpolonkai/kill-this-buffer-delete-this-window)
("M-k" . gpolonkai/undo-buffer-kill)
("C-b" . bury-buffer)
("/" . repeat)
:map isearch-mode-map
("<C-return>" . isearch-exit-other-end)
("<S-return>" . isearch-exit-mark-match)
:map gpolonkai/pers-map
("m" . hidden-mode-line-mode)
("C-i e" . "gergely@polonkai.eu")
("C-i w" . "http://gergely.polonkai.eu/")
("C-p" . package-list-packages)
("o i" . gpolonkai/visit-init-file)
("o o" . gpolonkai/visit-org-index)
("u" . browse-url-at-point)
("C" . clean-buffer-list))
;; TODO: This doesnt work with use-package and bind-key for some reason.
;; But why?
(define-key 'help-command (kbd "C-l") 'find-library)
(define-key 'help-command (kbd "C-f") 'find-function)
(define-key 'help-command (kbd "C-k") 'find-function-on-key)
(define-key 'help-command (kbd "C-v") 'find-variable)
;; Kudos goes to
;; http://endlessparentheses.com/leave-the-cursor-at-start-of-match-after-isearch.html
(defun isearch-exit-other-end ()
"Exit isearch, at the opposite end of the string."
(interactive)
(isearch-exit)
(goto-char isearch-other-end))
;; Kudos goes to http://emacs.stackexchange.com/a/31321/507
(defun isearch-exit-mark-match ()
"Exit isearch and mark the current match."
(interactive)
(isearch-exit)
(push-mark isearch-other-end)
(activate-mark))
;; Enable some functions
(put 'downcase-region 'disabled nil)
(put 'upcase-region 'disabled nil)
(put 'erase-buffer 'disabled nil)
(put 'narrow-to-region 'disabled nil)
(put 'set-goal-column 'disabled nil)
;; text-mode settings
(add-hook 'text-mode-hook (lambda () (visual-line-mode t)))
;; Add some symbols to be prettified
(setq prettify-symbols-alist
'(("lambda" . 955) ; λ
("function" . 402) ; ƒ
("->" . 8594) ; →
("=>" . 8658) ; ⇒
("map" . 8614) ; ↦
("not" . 172)) ; ¬
;; …and some pairs to complete
;; TODO: maybe add-to-list is a better way to do it
insert-pair-alist '(
(40 41) ; ()
(91 93) ; []
(123 125) ; {}
(60 62) ; <>
(34 34) ; ""
(39 39) ; ''
(96 39) ; `'
(8220 8221) ; “”
(8222 8221) ; „”
(8216 8217) ;
(8249 8250) ;
(8250 8249) ;
(171 187) ; «»
(187 171)) ; »«
;; Set the frame title to the current file name
frame-title-format '((:eval (concat system-name
": "
(if (buffer-file-name)
(abbreviate-file-name
(buffer-file-name))
"%b")))))
(defun gpolonkai/helm-ff-slash-dir-complete ()
"Make forward slash (/) do completion in helm."
(interactive)
(if (and (or
(equal "magit-status" (assoc-default 'name (helm-get-current-source)))
(equal "Find Files" (assoc-default 'name (helm-get-current-source))))
(stringp (helm-get-selection))
(file-directory-p (helm-get-selection)))
(helm-execute-persistent-action)
(insert "/")))
;; TODO: 'cursor-color is sometimes nil, but why?
(setq default-cursor-color (or (frame-parameter nil 'cursor-color) "#ffd85c"))
(setq yasnippet-can-fire-cursor-color "purple")
;; It will test whether it can expand, if yes, cursor color -> purple.
(defun yasnippet-can-fire-p (&optional field)
"Check if the word before point can be expanded with yasnippet.
TODO: What is FIELD for?"
(interactive)
(setq yas--condition-cache-timestamp (current-time))
(let (templates-and-pos)
(unless (and yas-expand-only-for-last-commands
(not (member last-command yas-expand-only-for-last-commands)))
(setq templates-and-pos (if field
(save-restriction
(narrow-to-region (yas--field-start field)
(yas--field-end field))
(yas--templates-for-key-at-point))
(yas--templates-for-key-at-point))))
(and templates-and-pos (first templates-and-pos))))
;; Taken from http://pages.sachachua.com/.emacs.d/Sacha.html
(defun sachachua/change-cursor-color-when-can-expand (&optional field)
"Change cursor color if the text before point can be expanded with yasnippet.
TODO: What is FIELD for?"
(interactive)
(when (eq last-command 'self-insert-command)
(set-cursor-color (if (sachachua/can-expand)
yasnippet-can-fire-cursor-color
default-cursor-color))))
(defun sachachua/can-expand ()
"Return t if right after an expandable thing."
(or (abbrev--before-point) (yasnippet-can-fire-p)))
;; SysAdmin Day to the calendar
(add-to-list 'holiday-other-holidays '(holiday-float 7 5 -1 "SysAdmin Day") t)
(add-to-list 'holiday-other-holidays '(holiday-fixed 10 21 "Reptile Awareness Day") t)
;;; init.el ends here ;;; init.el ends here