Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;; *** BASIC SET-UP ***
- ;;
- ;; Open emacs in full-size window
- ;;
- (add-to-list 'default-frame-alist '(fullscreen . maximized))
- ;;
- ;; Inhibit startscreen
- ;;
- (setq inhibit-startup-screen t)
- ;; Install package manager
- (setq package-archives
- '(("gnu" . "http://elpa.gnu.org/packages/")
- ("melpa" . "http://melpa.org/packages/")))
- (package-initialize)
- ;; Enable recent-file-mode
- (recentf-mode 1)
- (setq recentf-max-menu-items 35)
- (setq recentf-max-saved-items 35)
- (global-set-key "\C-x\ \C-r" 'recentf-open-files)
- ;; System locale to use for formatting time values.
- (setq system-time-locale "C") ; Make sure that the weekdays in the
- ; time stamps of your Org mode files and
- ; in the agenda appear in English.
- ;; Global visual line mode
- (global-visual-line-mode 1); proper line wrapping
- ;;
- ;; *** MARKDOWN ***
- ;;
- ;;
- ;; Set visual-line-mode automatically for .md/Markdown files
- ;;
- (add-hook 'markdown-mode-hook #'visual-line-mode)
- ;;
- ;; Set up Flyspell for text mode (but not for change-log-mode and log-edit-mode
- ;; (Can add additional exceptions as necessary.)
- ;;
- (dolist (hook '(text-mode-hook))
- (add-hook hook (lambda () (flyspell-mode 1))))
- (dolist (hook '(change-log-mode-hook log-edit-mode-hook))
- (add-hook hook (lambda () (flyspell-mode -1))))
- (setq ispell-dictionary "en_GB-ise") ;set the default dictionary
- ;;
- ;; Automatic flyspell-mode with markdown
- ;;
- (add-hook 'markdown-mode-hook 'flyspell-mode)
- ;;
- ;; Set new commands to switch between English and German dictionaries
- ;;
- (defun flyspell-german ()
- (interactive)
- (ispell-change-dictionary "de_DE")
- (flyspell-buffer))
- (defun flyspell-english ()
- (interactive)
- (ispell-change-dictionary "default")
- (flyspell-buffer))
- ;;
- ;; Attach shortcuts to change-dictionary commands
- ;;
- (global-set-key (kbd "<f5>") 'flyspell-english)
- (global-set-key (kbd "<f6>") 'flyspell-german)
- ;;
- ;; Auto-start gfm-mode with markdown.
- ;;
- (add-to-list 'auto-mode-alist '("\\.md\\'" . gfm-mode))
- ;;
- ;; Add new face for citations (including entire citation text)
- ;;
- (defface pandoc-citation-face
- '((t :foreground "dark orange"))
- "Face for pandoc citation syntax")
- (font-lock-add-keywords
- 'gfm-mode
- '(("\\B\\[[^][]*@[[:alnum:]_]+[^][]*\\]" . 'pandoc-citation-face)))
- ;;
- ;; ALTERNATIVE: Add new face for markdown mode: citations only
- ;;
- ;;(defface pandoc-citation-face
- ;; '((t :foreground "dark orange"))
- ;; "Face for pandoc citation syntax")
- ;;(font-lock-add-keywords
- ;; 'gfm-mode
- ;; '(("\\B\\(-?@[[:alnum:]_][-_[:alnum:]:.#$%&+?<>~/]+\\)" . 'pandoc-citation-face)))
- ;;
- ;; Auto insert text in new markdown files
- ;; See: http://www.howardism.org/Technical/Emacs/templates-tutorial.html
- ;;
- (use-package autoinsert
- :init
- ;; Don't want to be prompted before insertion:
- (setq auto-insert-query nil)
- (setq auto-insert-directory (locate-user-emacs-file "templates"))
- (add-hook 'find-file-hook 'auto-insert)
- (auto-insert-mode 1)
- :config
- (define-auto-insert "\\.md?$" "default-md.md"))
- ;;
- ;; Set asymmetric headings (# Heading instead of # Heading #)
- ;;
- (setq markdown-asymmetric-header t)
- ;;
- ;; Insert [@ ] ready for input with keystroke
- ;;
- (defun ref-insert ()
- (interactive)
- (insert "[@]")
- (backward-char)
- )
- (global-set-key (kbd "C-c r") 'ref-insert)
- ;;
- ;; HAVE DISABLED YASNIPPET BECAUSE IT INTERFERES WITH ORG-MODE KEY BINDINGS
- ;;
- ;; set-up yasnippet
- ;; See: http://www.howardism.org/Technical/Emacs/templates-tutorial.html
- ;;
- ;; (use-package yasnippet
- ;; :ensure t
- ;; :init
- ;; (yas-global-mode 1)
- ;; :config
- ;; (add-to-list 'yas-snippet-dirs (locate-user-emacs-file "snippets")))
- ;;
- ;; Set up automatic word-count (via Sacha Chua: https://sachachua.com/blog/2008/01/outlining-your-notes-with-org/
- ;;
- (defvar count-words-buffer
- nil
- "*Number of words in the buffer.")
- (defun wicked/update-wc ()
- (interactive)
- (setq count-words-buffer (number-to-string (count-words-buffer)))
- (force-mode-line-update))
- ; only setup timer once
- (unless count-words-buffer
- ;; seed count-words-paragraph
- ;; create timer to keep count-words-paragraph updated
- (run-with-idle-timer 1 t 'wicked/update-wc))
- ;; add count words paragraph the mode line
- (unless (memq 'count-words-buffer global-mode-string)
- (add-to-list 'global-mode-string "words: " t)
- (add-to-list 'global-mode-string 'count-words-buffer t))
- ;; count number of words in current paragraph
- (defun count-words-buffer ()
- "Count the number of words in the current paragraph."
- (interactive)
- (save-excursion
- (goto-char (point-min))
- (let ((count 0))
- (while (not (eobp))
- (forward-word 1)
- (setq count (1+ count)))
- count)))
- ;;
- ;; Enable SHIFT-Tab to move text four spaces to the left
- ;;
- (global-set-key (kbd "<backtab>") 'un-indent-by-removing-4-spaces)
- (defun un-indent-by-removing-4-spaces ()
- "remove 4 spaces from beginning of of line"
- (interactive)
- (save-excursion
- (save-match-data
- (beginning-of-line)
- ;; get rid of tabs at beginning of line
- (when (looking-at "^\\s-+")
- (untabify (match-beginning 0) (match-end 0)))
- (when (looking-at "^ ")
- (replace-match "")))))
- ;;
- ;; Enable easier window resizing with ALT+arrow keys
- ;;
- (global-set-key (kbd "<M-up>") 'shrink-window)
- (global-set-key (kbd "<M-down>") 'enlarge-window)
- (global-set-key (kbd "<M-left>") 'shrink-window-horizontally)
- (global-set-key (kbd "<M-right>")'enlarge-window-horizontally)
- ;;
- ;; Set apropos to sort search results by relevancy
- ;;
- (setq apropos-sort-by-scores t)
- ;;
- ;; Add euro symbol that can be displayed with M-x euro
- ;;
- (fset 'euro
- (lambda (&optional arg) "Keyboard macro." (interactive "p") (kmacro-exec-ring-item (quote ([24 56 return 35 120 50 48 65 67 return] 0 "%d")) arg)))
- ;;
- ;; Bind M-o to change windows (C-x o)
- ;;
- (global-set-key (kbd "M-o") 'other-window)
- ;;
- ;; Set IDO mode for file and directory finding
- ;;
- (ido-mode 1)
- (setq ido-everywhere t)
- (setq ido-enable-flex-matching t)
- ;;Add Neotree (toggle with F7) ;; Not currently using Neotree, using regular IDO-mode instead
- ;;
- ;; (add-to-list 'load-path "/home/john/.emacs.d/neotree")
- ;; (require 'neotree)
- ;; (global-set-key [f7] 'neotree-toggle)
- (custom-set-variables
- ;; custom-set-variables was added by Custom.
- ;; If you edit it by hand, you could mess it up, so be careful.
- ;; Your init file should contain only one such instance.
- ;; If there is more than one, they won't work right.
- '(ansi-color-faces-vector
- [default default default italic underline success warning error])
- '(ansi-color-names-vector
- ["#242424" "#e5786d" "#95e454" "#cae682" "#8ac6f2" "#333366" "#ccaa8f" "#f6f3e8"])
- '(custom-enabled-themes '(wheatgrass))
- '(ido-mode 'buffer nil (ido))
- '(org-agenda-files '("~/Documents/org/todo.org"))
- '(org-archive-subtree-add-inherited-tags t)
- '(org-export-backends '(ascii beamer html icalendar latex md odt))
- '(package-selected-packages
- '(helm-bibtex helm-org use-package lorem-ipsum auctex-latexmk auctex impatient-mode skewer-mode markdown-mode)))
- (custom-set-faces
- ;; custom-set-faces was added by Custom.
- ;; If you edit it by hand, you could mess it up, so be careful.
- ;; Your init file should contain only one such instance.
- ;; If there is more than one, they won't work right.
- '(markdown-blockquote-face ((t (:inherit font-lock-doc-face :foreground "dark orange"))))
- '(markdown-bold-face ((t (:inherit bold :foreground "gold"))))
- '(markdown-italic-face ((t (:inherit italic :foreground "magenta")))))
- ;;
- ;; helm-bibtex
- ;;
- (require 'helm)
- ;;
- ;; helm-bibtex set up location of Bibtex bibliographies
- ;;
- (setq bibtex-completion-bibliography
- '("/home/john/Documents/libraries/Religion.bib"
- "/home/john/Documents/libraries/Crime_and_violence.bib"))
- ;; helm-bibtex: keybindings (ORIGINAL CODE)
- (require 'helm-config)
- (global-set-key (kbd "<menu>") 'helm-command-prefix)
- (define-key helm-command-map "b" 'helm-bibtex)
- (define-key helm-command-map "B" 'helm-bibtex-with-local-bibliography)
- (define-key helm-command-map "n" 'helm-bibtex-with-notes)
- (define-key helm-command-map (kbd "<menu>") 'helm-resume)
- (setq bibtex-completion-format-citation-functions
- '((org-mode . bibtex-completion-format-citation-org-link-to-PDF)
- (latex-mode . bibtex-completion-format-citation-cite)
- (markdown-mode . bibtex-completion-format-citation-pandoc-citeproc)
- (gfm-mode . bibtex-completion-format-citation-pandoc-citeproc)
- (default . bibtex-completion-format-citation-default)))
- ;; Set up for lorem-ipsum
- (require 'lorem-ipsum)
- (global-set-key (kbd "C-c M-l s") 'lorem-ipsum-insert-sentences)
- (global-set-key (kbd "C-c M-l p") 'lorem-ipsum-insert-paragraphs)
- (global-set-key (kbd "C-c M-l l") 'lorem-ipsum-insert-list)
- ;;
- ;; **ORG-MODE SETTINGS **
- ;;
- ;;
- ;; Activate Org-mode
- ;;
- ;; (require 'org)
- ;; (define-key global-map "\C-cl" 'org-store-link)
- ;; (define-key global-map "\C-ca" 'org-agenda)
- ;; (define-key global-map "\C-cc" 'org-capture)
- ;; (define-key global-map "\C-cb" 'org-switchb)
- (require 'org)
- (global-set-key "\C-cl" 'org-store-link)
- (global-set-key "\C-ca" 'org-agenda)
- (global-set-key "\C-cc" 'org-capture)
- (global-set-key "\C-cb" 'org-switchb)
- (setq org-log-done t)
- ;;
- ;; Open org agenda (todo.org) automatically
- ;;
- (find-file "~/Documents/org/todo.org")
- ;;
- ;; Enable opening org-agenda with "C-c a" globally
- ;;
- (global-set-key (kbd "C-c a") 'org-agenda)
- ;; Enable transient mark mode
- (transient-mark-mode 1)
- ;; Set the workflow-states
- (setq org-todo-keywords
- '((sequence "TODO" "IN-PROGRESS" "WAITING" "DONE")))
- ;;
- ;; Set variable org-agenda-files (where TODOs will be searched for)
- ;;
- (setq org-agenda-files (list "~/Documents/org/gtd.org"
- "~/Documents/org/journal.org"
- "~/Documents/org/todo.org"
- "~/Documents/org/notes.org"))
- ;;
- ;; Set visual line mode for org (aimed mainly at setting it for capture)
- ;;
- (add-hook 'org-mode-hook #'visual-line-mode)
- (add-hook 'org-capture-mode-hook #'visual-line-mode)
- ;;
- ;; Set up a capture location
- ;;
- (setq org-default-notes-file (concat org-directory "~/Documents/org/notes.org"))
- (define-key global-map "\C-cc" 'org-capture)
- ;;
- ;; Capture templates
- ;;
- (setq org-capture-templates
- '(("t" "Todo" entry (file+headline "~/Documents/org/gtd.org" "Tasks")
- "* TODO %?\n %i\n %a")
- ("n" "Note" entry (file+datetree "~/Documents/org/notes.org" "Observations")
- "* %?\nEntered on %U\n %a")
- ("b" "Book" entry (file+datetree "~/Documents/org/notes.org" "Books read")
- "* Book finished: %?\nEntered on %U\n %a")
- ("v" "Video" entry (file+datetree "~/Documents/org/notes.org" "Films and shows watched")
- "* Film or show watched: %?\nEntered on %U\n %a")
- ("a" "Articles" entry (file+datetree "~/Documents/org/notes.org" "Articles of note")
- "* Article to note: %?\nEntered on %U\n %a")
- ("j" "Journal Entry"
- entry (file+datetree "~/Documents/org/journal.org")
- "* Event: %?\n\n %i\n\n From: %a"
- :empty-lines 1)
- ))
- ;; ("j" "Journal" entry (file+datetree "~/Documents/org/journal.org")
- ;; "* %?\nEntered on %U\n %a")))
- ;;
- ;; Set-up refile target (will look at top three layers of headings in org-agenda-files
- ;;
- ;; (setq org-refile-targets '((org-agenda-files :maxlevel . 3)))
- (setq org-refile-targets (quote (("archive.org" :maxlevel . 2)
- )))
- ;; Macros
- (fset 'macro-add-comment
- (kmacro-lambda-form [?\[ ?/ ?/ ?\] ?: ?\S- ?# ? ?\( ?\) left] 0 "%d"))
- (global-set-key "\C-x\C-kc" 'macro-add-comment)
- ;; AUCTeX set-up
- (setq TeX-auto-save t)
- (setq TeX-parse-self t)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement