Browse Source

Improve Org configuration

master
Riyyi 4 years ago
parent
commit
ec311c6c2d
  1. 146
      .config/emacs/config.org

146
.config/emacs/config.org

@ -30,7 +30,7 @@
- [[#org-packages][Org Packages]] - [[#org-packages][Org Packages]]
- [[#org-toc][Org ToC]] - [[#org-toc][Org ToC]]
- [[#org-roam][Org Roam]] - [[#org-roam][Org Roam]]
- [[#org-exporters][Org Exporters]] - [[#org-export-packages][Org Export Packages]]
- [[#completion][Completion]] - [[#completion][Completion]]
- [[#company][Company]] - [[#company][Company]]
- [[#flycheck][Flycheck]] - [[#flycheck][Flycheck]]
@ -49,6 +49,12 @@
- [[#formatting][Formatting]] - [[#formatting][Formatting]]
- [[#hide-elements][Hide Elements]] - [[#hide-elements][Hide Elements]]
- [[#org][Org]] - [[#org][Org]]
- [[#org-config][Org Config]]
- [[#org-agenda][Org Agenda]]
- [[#org-keys][Org Keys]]
- [[#org-links][Org Links]]
- [[#org-source-code-blocks][Org Source Code Blocks]]
- [[#org-export][Org Export]]
- [[#recentf][Recentf]] - [[#recentf][Recentf]]
- [[#tabs][Tabs]] - [[#tabs][Tabs]]
- [[#utf-8][UTF-8]] - [[#utf-8][UTF-8]]
@ -440,7 +446,7 @@ Easily searchable .org files via Deft.
(evil-set-initial-state 'deft-mode 'insert)) (evil-set-initial-state 'deft-mode 'insert))
#+END_SRC #+END_SRC
**** Org Exporters **** Org Export Packages
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
;; HTML exporter ;; HTML exporter
(use-package htmlize (use-package htmlize
@ -841,31 +847,92 @@ Setup file backups versioning.
** Org ** Org
*** Org Config
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(use-package org (use-package org
:custom
(org-directory (concat (getenv "HOME") "/documents/org"))
(org-ellipsis " ↴")
(org-latex-toc-command "\\newpage \\tableofcontents \\newpage")
(org-return-follows-link t)
(org-src-fontify-natively t)
(org-src-window-setup 'current-window)
:config :config
;; Do not open .org files in a split window (setq org-directory (concat (getenv "HOME") "/documents/org"))
(setq org-default-notes-file (expand-file-name "notes.org" org-directory))
(setq org-adapt-indentation nil)
(setq org-ellipsis "⤵")
;; Enable structured template completion
(add-to-list 'org-modules 'org-tempo t)
(add-to-list 'org-structure-template-alist
'("el" . "src emacs-lisp"))
)
#+END_SRC
*** Org Agenda
#+BEGIN_SRC emacs-lisp
(use-package org-agenda
:ensure nil
:defer t
:config
(setq org-agenda-files `(,org-directory ,user-emacs-directory))
(setq org-agenda-span 14)
(setq org-agenda-window-setup 'current-window)
(evil-set-initial-state 'org-agenda-mode 'motion)
)
#+END_SRC
*** Org Keys
#+BEGIN_SRC emacs-lisp
(use-package org-keys
:ensure nil
:config
(setq org-return-follows-link t)
)
#+END_SRC
*** Org Links
#+BEGIN_SRC emacs-lisp
(use-package ol
:ensure nil
:config
;; Do not open links to .org files in a split window
(add-to-list 'org-link-frame-setup '(file . find-file)) (add-to-list 'org-link-frame-setup '(file . find-file))
) )
#+END_SRC
*** Org Source Code Blocks
#+BEGIN_SRC emacs-lisp
(use-package org-src
:ensure nil
:config
(setq org-edit-src-content-indentation 0)
(setq org-src-fontify-natively t)
(setq org-src-preserve-indentation t)
(setq org-src-tab-acts-natively t)
(setq org-src-window-setup 'current-window)
)
#+END_SRC
*** Org Export
;; Enable syntax highlighting when exporting to .pdf #+BEGIN_SRC emacs-lisp
;; Load latex exporter ;; Org exporter
(use-package ox
:ensure nil
:defer t
:config
(setq org-export-coding-system 'utf-8-unix)
)
;; Org latex exporter
(use-package ox-latex (use-package ox-latex
:ensure nil ; ox-latex.el is part of org :ensure nil
:defer t :defer t
:after org
:custom
;; Define how minted is added to source code blocks
(org-latex-listings 'minted)
(org-latex-minted-options '(("frame" "lines") ("linenos=true")))
:config :config
;; Define how minted (highlighted src code) is added to src code blocks
(setq org-latex-listings 'minted)
(setq org-latex-minted-options '(("frame" "lines") ("linenos=true")))
;; Set 'Table of Contents' layout
(setq org-latex-toc-command "\\newpage \\tableofcontents \\newpage")
;; Add minted package to every LaTeX header ;; Add minted package to every LaTeX header
(add-to-list 'org-latex-packages-alist '("" "minted")) (add-to-list 'org-latex-packages-alist '("" "minted"))
;; Append -shell-escape so pdflatex exports minted correctly ;; Append -shell-escape so pdflatex exports minted correctly
@ -1106,7 +1173,8 @@ Functions that use package functionality.
;; Buffer name does match below blacklist ;; Buffer name does match below blacklist
(string-match-p (concat "\\(CAPTURE-\\)?" (format-time-string "%Y%m%d%H%M%S") "-.*\\.org") name) (string-match-p (concat "\\(CAPTURE-\\)?" (format-time-string "%Y%m%d%H%M%S") "-.*\\.org") name)
(string-match-p (string-match-p
(concat "^\\*\\(" (concat "^ ?\\*\\("
"Agenda Commands\\|"
"e?shell\\|" "e?shell\\|"
"Compile-Log\\|" "Compile-Log\\|"
"Completions\\|" "Completions\\|"
@ -1117,7 +1185,9 @@ Functions that use package functionality.
"helpful\\|" "helpful\\|"
"httpd\\|" "httpd\\|"
"iph\\|" ; lsp php "iph\\|" ; lsp php
"org-roam" "org-roam\\|"
"Org tags\\|"
"Org todo"
"\\).*") "\\).*")
name) name)
))) )))
@ -1206,12 +1276,14 @@ Fix keybinds..
"Org return key at point. "Org return key at point.
If point is on: If point is on:
checkbox -- toggle it
link -- follow it link -- follow it
otherwise -- run the default (evil-ret) expression" otherwise -- run the default (evil-ret) expression"
(interactive) (interactive)
(let ((type (org-element-type (org-element-context)))) (let ((type (org-element-type (org-element-context))))
(pcase type (pcase type
('link (if org-return-follows-link (org-open-at-point) (evil-ret))) ('link (if org-return-follows-link (org-open-at-point) (evil-ret)))
((guard (org-at-item-checkbox-p)) (org-toggle-checkbox))
(_ (evil-ret)) (_ (evil-ret))
))) )))
#+END_SRC #+END_SRC
@ -1376,9 +1448,13 @@ Set keybinds to native functionality.
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
;; Org-mode ;; Org-mode
(with-eval-after-load 'org-capture
(define-key org-capture-mode-map (kbd "M-c") #'org-capture-finalize)
(define-key org-capture-mode-map (kbd "M-w") #'org-capture-refile)
(define-key org-capture-mode-map (kbd "M-k") #'org-capture-kill))
(define-key org-mode-map (kbd "M-c") #'org-edit-special) (define-key org-mode-map (kbd "M-c") #'org-edit-special)
(define-key org-src-mode-map (kbd "M-c") #'org-edit-src-exit) (define-key org-src-mode-map (kbd "M-c") #'org-edit-src-exit)
(define-key org-src-mode-map (kbd "M-z") #'org-edit-src-abort) (define-key org-src-mode-map (kbd "M-k") #'org-edit-src-abort)
#+END_SRC #+END_SRC
** Set Package ** Set Package
@ -1523,9 +1599,11 @@ Set keybinds to functionality of installed packages.
;; Org ;; Org
(general-def 'normal org-mode-map (general-def 'normal org-mode-map
"RET" 'dot/org-ret-at-point) "RET" #'dot/org-ret-at-point)
(general-def 'insert org-mode-map (general-def 'insert org-mode-map
"RET" 'evil-ret) "RET" #'evil-ret)
(general-def 'motion org-agenda-mode-map
"RET" #'org-agenda-switch-to)
) )
#+END_SRC #+END_SRC
@ -1606,16 +1684,17 @@ General.el ~leader key binds.
;; Notes ;; Notes
"n" '(:ignore t :which-key "notes") "n" '(:ignore t :which-key "notes")
"n r" '(:ignore t :which-key "roam") "n a" '(org-agenda :which-key "Org agenda")
"n r b" '(org-roam-switch-to-buffer :which-key "Switch to buffer") "n r" '(:ignore t :which-key "org-roam")
"n r c" '(org-roam-capture :which-key "Org Roam Capture") "n r b" '(org-roam-switch-to-buffer :which-key "Switch buffer")
"n r c" '(org-roam-capture :which-key "Capture")
"n r C" '(org-roam-db-build-cache :which-key "Build cache") "n r C" '(org-roam-db-build-cache :which-key "Build cache")
"n r f" '(org-roam-find-file :which-key "Find file") "n r f" '(org-roam-find-file :which-key "Find file")
"n r g" '(org-roam-graph-show :which-key "Show graph") "n r g" '(org-roam-graph-show :which-key "Show graph")
"n r i" '(org-roam-insert :which-key "Insert") "n r i" '(org-roam-insert :which-key "Insert")
"n r I" '(org-roam-insert-immediate :which-key "Insert without org-capture") "n r I" '(org-roam-insert-immediate :which-key "Insert (without capture)")
"n r r" '(org-roam :which-key "Org Roam") "n r r" '(org-roam :which-key "Toggle side-buffer")
"n r s" '(org-roam-server-mode :which-key "Org Roam Server") "n r s" '(org-roam-server-mode :which-key "Toggle server")
;; Open ;; Open
"o" '(:ignore t :which-key "open") "o" '(:ignore t :which-key "open")
@ -1705,9 +1784,7 @@ https://github.com/suyashbire1/emacs.d/blob/master/init.el
(local-leader org-mode-map (local-leader org-mode-map
"'" '(org-edit-special :which-key "Org edit") "'" '(org-edit-special :which-key "Org edit")
"c" '(org-edit-special :which-key "Org edit")
"e" '(org-export-dispatch :which-key "Org export") "e" '(org-export-dispatch :which-key "Org export")
"l" '(org-insert-link :which-key "Org make link")
"o" '(org-open-at-point :which-key "Org open at point") "o" '(org-open-at-point :which-key "Org open at point")
"i" '(:ignore t :which-key "insert") "i" '(:ignore t :which-key "insert")
@ -1715,6 +1792,10 @@ https://github.com/suyashbire1/emacs.d/blob/master/init.el
"i h" '(org-table-insert-hline :which-key "Insert table hline") "i h" '(org-table-insert-hline :which-key "Insert table hline")
"i H" '(org-table-hline-and-move :which-key "Insert table hline and move") "i H" '(org-table-hline-and-move :which-key "Insert table hline and move")
"i r" '(org-table-insert-row :which-key "Insert table row") "i r" '(org-table-insert-row :which-key "Insert table row")
"i t" '(org-insert-structure-template :which-key "Insert template")
"l" '(:ignore t :which-key "links")
"l l" '(org-insert-link :which-key "Org make link")
"q" '(org-set-tags-command :which-key "Org tags") "q" '(org-set-tags-command :which-key "Org tags")
@ -1731,6 +1812,9 @@ https://github.com/suyashbire1/emacs.d/blob/master/init.el
"t" '(org-todo :which-key "Org todo") "t" '(org-todo :which-key "Org todo")
) )
(local-leader org-src-mode-map
"k" '(org-edit-src-abort :which-key "Org Edit abort"))
(local-leader elfeed-search-mode-map (local-leader elfeed-search-mode-map
"g" '(elfeed-search-update--force :which-key "Elfeed refresh buffer") "g" '(elfeed-search-update--force :which-key "Elfeed refresh buffer")
"G" '(elfeed-search-fetch :which-key "Elfeed update feeds") "G" '(elfeed-search-fetch :which-key "Elfeed update feeds")

Loading…
Cancel
Save