Commit 1e3306e9 authored by Todor Kondic's avatar Todor Kondic
Browse files

Update emacs setup

parent 1c04c8ab
#!/bin/bash
source "$HOME/.profile"
cd "$HOME"
mkdir .emacs.d
emacs --batch --eval "(require 'org)" --eval "(org-babel-tangle-file \"${HOME}/.emacs.org\")"
export GUIX_PROFILE="$HOME/.man-guix-prof"
source "$GUIX_PROFILE/etc/profile"
emacs --batch -l "$HOME/.emacs.d/eci-initial-setup.el"
#+TITLE: Emacs settings
#+PROPERTY: header-args :tangle ~/.emacs.d/eci-init.el
Configuration file for Emacs is now being kept as an Org file, because
of somewhat better clarity. This file needs to be tangled first in
order for configuration to take place.
# Emacs startup in Org
* Tangling of this file
#+BEGIN_SRC emacs-lips
(require 'ob-tangle)
(defun my--tangle-byte-compile-org ()
"Tangles .emacs.org and byte compiles ~/.emacs.d/"
(interactive)
(when (equal (buffer-name)
"eci-init.org")
(org-babel-tangle-file "~/.emacs.d/eci-init.org" "~/.emacs.d/eci-init.el")
(byte-recompile-directory (expand-file-name user-emacs-directory) 0)))
#+END_SRC
* MELPA
#+BEGIN_SRC emacs-lisp
(require 'package)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
;; Comment/uncomment this line to enable MELPA Stable if desired. See `package-archive-priorities`
;; and `package-pinned-packages`. Most users will not need or want to do this.
;;(add-to-list 'package-archives '("melpa-stable" . "https://stable.melpa.org/packages/") t)
(package-initialize)
#+END_SRC
* Org Mode
** Babel
#+BEGIN_SRC emacs-lisp
;(load "~/.emacsincludes/org-ctags.el")
;(load "~/.emacsincludes/org.el")
(org-babel-do-load-languages
'org-babel-load-languages
'((maxima . t)
(R . t)
(python . t)))
#+END_SRC
** Dynamic Blocks
#+BEGIN_SRC emacs-lisp
(add-hook 'org-export-before-processing-hook (lambda (x) (org-update-all-dblocks)))
#+END_SRC
* Emacs Tweaks
#+BEGIN_SRC emacs-lisp
(savehist-mode 1)
(column-number-mode 1)
(scroll-bar-mode 0)
(tool-bar-mode 0)
;(menu-bar-mode 0)
(require 'use-package)
;; Save all tempfiles in $TMPDIR/emacs$UID/
(defconst emacs-tmp-dir (format "%s/%s/%s/%s" (getenv "HOME") "tmp" "emacs" (user-uid)))
(setq backup-directory-alist
`((".*" . ,emacs-tmp-dir)))
(setq auto-save-file-name-transforms
`((".*" ,emacs-tmp-dir t)))
(setq auto-save-list-file-prefix
emacs-tmp-dir)
(set-frame-font "Hack 12" nil t)
(show-paren-mode 1); Matches parentheses and such in every mode
(setq inhibit-splash-screen t); Disable splash screen
(setq calendar-week-start-day 1); Calender should start on Monday
(setq prettify-symbols-alist
'(
("lambda" . 955) ; λ
("->" . 8594) ; →
("=>" . 8658) ; ⇒
("map" . 8614) ; ↦
))
(ivy-mode 1)
(setq ivy-use-virtual-buffers t)
(setq ivy-count-format "(%d/%d) ")
(when (fboundp 'winner-mode)
(winner-mode 1))
(setq ring-bell-function 'ignore)
;; Status bar
(setq-default mode-line-format (list " " 'mode-line-modified ;; the "**" at the beginning
"--" 'mode-line-position ;; line, column, file %
"--" '(:eval (format-time-string "%c" (current-time)))
"--" 'mode-line-buffer-identification ;; buffer file name
"--" 'mode-line-modes ;; major and minor modes in effect
"-%-")) ;; dashes sufficient to fill rest of modeline.
(setq custom-file "~/.emacs.d/custom.el")
#+END_SRC
* Smartparens
#+BEGIN_SRC emacs-lisp
(require 'smartparens-config)
;; (add-hook 'ess-mode-hook 'turn-on-smartparens-strict-mode)
(add-hook 'ess-mode-hook 'turn-on-smartparens-mode)
(defmacro def-pairs (pairs)
"Define functions for pairing. PAIRS is an alist of (NAME . STRING)
conses, where NAME is the function name that will be created and
STRING is a single-character string that marks the opening character.
(def-pairs ((paren . \"(\")
(bracket . \"[\"))
defines the functions WRAP-WITH-PAREN and WRAP-WITH-BRACKET,
respectively."
`(progn
,@(cl-loop for (key . val) in pairs
collect
`(defun ,(read (concat
"wrap-with-"
(prin1-to-string key)
"s"))
(&optional arg)
(interactive "p")
(sp-wrap-with-pair ,val)))))
(def-pairs ((paren . "(")
(bracket . "[")
(brace . "{")
;; (single-quote . "'")
(double-quote . "\"")
(back-quote . "`")))
(bind-keys
:map smartparens-mode-map
("C-M-a" . sp-beginning-of-sexp)
("C-M-e" . sp-end-of-sexp)
("C-<down>" . sp-down-sexp)
("C-<up>" . sp-up-sexp)
("M-<down>" . sp-backward-down-sexp)
("M-<up>" . sp-backward-up-sexp)
("C-M-f" . sp-forward-sexp)
("C-M-b" . sp-backward-sexp)
("C-M-n" . sp-next-sexp)
("C-M-p" . sp-previous-sexp)
("C-S-f" . sp-forward-symbol)
("C-S-b" . sp-backward-symbol)
("C-<right>" . sp-forward-slurp-sexp)
("M-<right>" . sp-forward-barf-sexp)
("C-<left>" . sp-backward-slurp-sexp)
("M-<left>" . sp-backward-barf-sexp)
("C-M-t" . sp-transpose-sexp)
("C-M-k" . sp-kill-sexp)
("C-k" . sp-kill-hybrid-sexp)
("M-k" . sp-backward-kill-sexp)
("C-M-w" . sp-copy-sexp)
("C-M-d" . delete-sexp)
("M-<backspace>" . backward-kill-word)
("C-<backspace>" . sp-backward-kill-word)
([remap sp-backward-kill-word] . backward-kill-word)
("M-[" . sp-backward-unwrap-sexp)
("M-]" . sp-unwrap-sexp)
("C-x C-t" . sp-transpose-hybrid-sexp)
("C-c (" . wrap-with-parens)
("C-c [" . wrap-with-brackets)
("C-c {" . wrap-with-braces)
("C-c '" . wrap-with-single-quotes)
("C-c \"" . wrap-with-double-quotes)
("C-c _" . wrap-with-underscores)
("C-c `" . wrap-with-back-quotes))
#+END_SRC
* Global Keys :keys:gkeys:
#+BEGIN_SRC emacs-lisp
;; (global-set-key (kbd "C-c m r") 'refill-mode)
(global-set-key (kbd "<escape>") 'god-local-mode)
(global-set-key (kbd "<f1> r") 'point-to-register)
(global-set-key (kbd "<f1> j") 'jump-to-register)
(global-set-key (kbd "<f6>") 'other-frame)
(global-set-key (kbd "<f7>") 'make-frame-command)
(global-set-key (kbd "C-x g") 'magit-status)
(global-set-key (kbd "ESC ,") 'eshell)
(global-set-key (kbd "C-s") 'counsel-grep-or-swiper)
(global-set-key (kbd "M-x") 'counsel-M-x)
(global-set-key (kbd "C-x C-f") 'counsel-find-file)
(global-set-key (kbd "<f1> f") 'counsel-describe-function)
(global-set-key (kbd "<f1> v") 'counsel-describe-variable)
(global-set-key (kbd "<f1> l") 'counsel-find-library)
(global-set-key (kbd "<f2> i") 'counsel-info-lookup-symbol)
(global-set-key (kbd "<f2> u") 'counsel-unicode-char)
(global-set-key (kbd "C-c g") 'counsel-git)
(global-set-key (kbd "C-c j") 'counsel-git-grep)
(global-set-key (kbd "C-c k") 'counsel-ag)
(global-set-key (kbd "C-c m") 'counsel-imenu)
(global-set-key (kbd "C-x l") 'counsel-locate)
(global-set-key (kbd "C-x j") 'counsel-file-jump)
(global-set-key (kbd "M--") 'dabbrev-expand)
;; (global-set-key (kbd "C--") 'undo)
(with-eval-after-load 'counsel-gtags
(define-key counsel-gtags-mode-map (kbd "M-t") 'counsel-gtags-find-definition)
(define-key counsel-gtags-mode-map (kbd "M-r") 'counsel-gtags-find-reference)
(define-key counsel-gtags-mode-map (kbd "M-s") 'counsel-gtags-find-symbol)
(define-key counsel-gtags-mode-map (kbd "M-,") 'counsel-gtags-go-backward))
(with-eval-after-load 'company-mode
(define-key company-active-map (kbd "M-n") nil)
(define-key company-active-map (kbd "M-p") nil)
(define-key company-active-map (kbd "M-,") 'company-select-next)
(define-key company-active-map (kbd "M-k") 'company-select-previous)
(define-key company-active-map [return] nil)
(define-key company-active-map [tab] 'company-complete-common)
(define-key company-active-map (kbd "TAB") 'company-complete-common)
(define-key company-active-map (kbd "M-TAB") 'company-complete-selection)
(setq company-dabbrev-downcase 0)
(company-tng-configure-default))
#+END_SRC
* Ivy
#+BEGIN_SRC emacs-lisp
(defun tk-default-completion ()
(interactive)
"Locally revert completion variables to their default values."
(setq-local completing-read-function #'completing-read-default)
(setq-local completion-in-region-function #'completion--in-region))
(setq ivy-use-selectable-prompt t)
(ivy-set-occur 'swiper 'swiper-occur)
(ivy-set-occur 'ivy-switch-buffer 'ivy-switch-buffer-occur)
(setq ivy-use-virtual-buffers t)
(setq enable-recursive-minibuffers t)
(setq ivy-auto-select-single-candidate 1)
(global-set-key (kbd "C-s") 'counsel-grep-or-swiper)
(global-set-key (kbd "M-x") 'counsel-M-x)
(global-set-key (kbd "C-x C-f") 'counsel-find-file)
(global-set-key (kbd "<f1> f") 'counsel-describe-function)
(global-set-key (kbd "<f1> v") 'counsel-describe-variable)
(global-set-key (kbd "<f1> l") 'counsel-find-library)
(global-set-key (kbd "<f2> i") 'counsel-info-lookup-symbol)
(global-set-key (kbd "<f2> u") 'counsel-unicode-char)
(global-set-key (kbd "C-c g") 'counsel-git)
(global-set-key (kbd "C-c j") 'counsel-git-grep)
(global-set-key (kbd "C-c k") 'counsel-ag)
(global-set-key (kbd "C-c m") 'counsel-imenu)
(global-set-key (kbd "C-x l") 'counsel-locate)
(global-set-key (kbd "C-x j") 'counsel-file-jump)
#+END_SRC
* Tramp
#+BEGIN_SRC emacs-lisp
(setq tramp-default-method "ssh")
#+END_SRC
* Company Mode
#+BEGIN_SRC emacs-lisp
(setq company-dabbrev-downcase nil)
(setq company-dabbrev-ingore-case 1)
(setq company-idle-delay 0.3)
(setq company-minimum-prefix-length 1)
#+END_SRC
* Eshell
#+BEGIN_SRC emacs-lisp
(require 'eshell)
(require 'em-smart)
(setq eshell-where-to-jump 'begin)
(setq eshell-review-quick-commands nil)
(setq eshell-smart-space-goes-to-end t)
#+END_SRC
* Scheme
** Guile
#+BEGIN_SRC emacs-lisp
;;; define* now works
(setq guile-imenu-generic-expression
'(nil
"^(\\(define\\*\\)\\s-+(?\\(\\sw+\\)" 2))
(put 'define* 'scheme-ident-function 1)
#+END_SRC
** Paredit
#+BEGIN_SRC emacs-lisp
(autoload 'enable-paredit-mode "paredit" "Turn on pseudo-structural editing of Lisp code." t)
(add-hook 'emacs-lisp-mode-hook #'enable-paredit-mode)
(add-hook 'eval-expression-minibuffer-setup-hook #'enable-paredit-mode)
(add-hook 'ielm-mode-hook #'enable-paredit-mode)
(add-hook 'lisp-mode-hook #'enable-paredit-mode)
(add-hook 'lisp-interaction-mode-hook #'enable-paredit-mode)
(add-hook 'scheme-mode-hook 'enable-paredit-mode)
#+END_SRC
** Company
#+BEGIN_SRC emacs-lisp
;;(add-hook 'scheme-mode-hook #'enable-mode)
#+END_SRC
** Geiser
#+BEGIN_SRC emacs-lisp
(setq geiser-guile-binary '("guile" "--no-auto-compile"))
(setq geiser-implementations-alist '("guile"
((regexp "\\.scm$")
guile)))
(setq geiser-default-implementation 'guile)
(setq geiser-active-implementations '(guile))
(setq geiser-guile-manual-lookup-nodes '("Guile" "guile" "guile-2.0" "guile-2.2"))
(setq geiser-guile-load-path (mapcar (lambda (p) (concat (getenv "HOME") "/" p))
'("cabinet/projects/ARCTIC/code/engine"
"cabinet/projects/ARCTIC/code/user"
"cabinet/projects/SCHEMETRAN/code/src")))
(add-hook 'scheme-mode-hook
(lambda ()
(defun guile--manual-look-up (id mod)
(let ((info-lookup-other-window-flag
geiser-guile-manual-lookup-other-window-p))
(info-lookup-symbol (symbol-name id) 'geiser-guile-mode))
(when geiser-guile-manual-lookup-other-window-p
(switch-to-buffer-other-window "*info*"))
(search-forward (format "%s" id) nil t))))
#+END_SRC
* Python
#+BEGIN_SRC emacs-lisp
(setq python-shell-interpreter "python3")
#+END_SRC
* ESS
#+BEGIN_SRC emacs-lisp
(add-hook 'ess-mode-hook 'company-mode)
(require 'ess)
(require 'ess-site)
(setq display-buffer-alist
`(("*R Dired"
(display-buffer-reuse-window display-buffer-in-side-window)
(side . right)
(slot . -1)
(window-width . 0.33)
(reusable-frames . nil))
("*R"
(display-buffer-reuse-window display-buffer-at-bottom)
(window-width . 0.5)
(reusable-frames . nil))
("*Help"
(display-buffer-reuse-window display-buffer-in-side-window)
(side . right)
(slot . 1)
(window-width . 0.33)
(reusable-frames . nil))))
(setq ess-style 'RStudio)
;; (setq skeleton-pair t)
;; (define-key ess-mode-map (kbd "(") 'skeleton-pair-insert-maybe)
;; (define-key ess-mode-map (kbd "[") 'skeleton-pair-insert-maybe)
;; (define-key ess-mode-map (kbd "{") 'skeleton-pair-insert-maybe)
;; (define-key ess-mode-map (kbd "\"") 'skeleton-pair-insert-maybe)
;; (define-key ess-mode-map (kbd "\'") 'skeleton-pair-insert-maybe)
;; (define-key ess-mode-map (kbd "\`") 'skeleton-pair-insert-maybe)
#+END_SRC
;;; This is used to set emacs up before the first run.
(require 'org)
(require 'ob-tangle)
(org-babel-tangle-file "~/.emacs.d/eci-init.org" "~/.emacs.d/eci-init.el")
;;; Commentary:
;;;
;;; This is the top-level /default/ Emacs configuration file. Below
;;; are definitions of the package repositories needed for basic
;;; functionality and then functions to load the definitions contained
;;; in an org mode file.
(defvar eci-init "~/.emacs.d/eci-init.el")
(setq custom-file "~/.emacs.d/custom.el")
(if (file-exists-p eci-init) (load eci-init) nil)
(if (file-exists-p custom-file) (load custom-file) nil)
- name: Copy .emacs.
- name: Copy .emacs.d.
copy:
src: files/home/user/.emacs
dest: "/home/{{ item.login }}/.emacs"
become_user: "{{ item.login }}"
loop: "{{ users }}"
- name: Copy .emacs.org.
copy:
src: files/home/user/.emacs.org
dest: "/home/{{ item.login }}/.emacs.org"
become_user: "{{ item.login }}"
src: files/home/user/.emacs.d
dest: "/home/{{ item.login }}/.emacs.d"
owner: "{{ item.login }}"
mode: 0700
loop: "{{ users }}"
- name: Copy config-emacs.
copy:
copy:
src: files/home/user/.config/config-emacs
dest: "/home/{{ item.login }}/.config/config-emacs"
mode: 0744
owner: "{{ item.login }}"
loop: "{{ users }}"
mode: 0700
- name: Configure emacs.
command: /home/{{ item.login }}/.config/config-emacs
become_user: "{{ item.login }}"
loop: "{{ users }}"
- name: Copy emacs.desktop.
copy:
src: files/home/user/Desktop/emacs.desktop
dest: "/home/{{ item.login }}/Desktop/emacs.desktop"
mode: 0744
become_user: "{{ item.login }}"
loop: "{{ users }}"
# - name: Copy emacs.desktop.
# copy:
# src: files/home/user/Desktop/emacs.desktop
# dest: "/home/{{ item.login }}/Desktop/emacs.desktop"
# mode: 0744
# become_user: "{{ item.login }}"
# loop: "{{ users }}"
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment