Skip to content
Snippets Groups Projects
Commit 7dbe9d34 authored by Michael Hauspie's avatar Michael Hauspie
Browse files

Start a transition to complete use-package usage

parent 398ef624
No related branches found
No related tags found
No related merge requests found
......@@ -25,3 +25,4 @@ history
.env
session.*
projectile.cache
/eln-cache
......@@ -54,7 +54,7 @@ Some of my configuration entries where borrowed from other people, see
* Packages management
I use [[https://elpa.gnu.org][Elpa]], [[https://melpa.org][Melpa]] and [[http://orgmode.org][Org mode]] packages repositories, thus I need to add them to the =package-archives= list
I use Melpa packages repositories, thus I need to add them to the =package-archives= list
For older emacs version, fix some gnutls algorithm priority
......@@ -66,10 +66,8 @@ Some of my configuration entries where borrowed from other people, see
#+BEGIN_SRC emacs-lisp
(require 'package)
(add-to-list 'package-archives '("gnu" . "https://elpa.gnu.org/packages/") t)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
(add-to-list 'package-archives '("org" . "https://orgmode.org/elpa/") t)
(package-initialize)
(unless (fboundp 'package-activate-all) (package-initialize))
#+END_SRC
......@@ -114,6 +112,12 @@ Some of my configuration entries where borrowed from other people, see
)
#+end_src
some packages I use depends on =pkg-info=
#+begin_src emacs-lisp
(use-package pkg-info)
#+end_src
** Non package modules
Add a folder for .el files that are not available as packages
......@@ -414,8 +418,10 @@ Vertico and Marginlia upgrades the minibuffer completion window by making it mor
#+BEGIN_SRC emacs-lisp
(use-package org
;; :ensure org-plus-contrib
;; :ensure org-tempo
:bind (("C-c l" . 'org-store-link)
("C-c a" . 'org-agenda)
("C-c c" . 'org-capture)
)
:custom
;; Tab keeps indenting in src blocks
(org-src-tab-acts-natively t)
......@@ -423,16 +429,76 @@ Vertico and Marginlia upgrades the minibuffer completion window by making it mor
(org-completion-use-ido t)
;; hide emphasis markers
;; (org-hide-emphasis-markers t)
:config
;; (require 'org-tempo)
(add-hook 'org-mode-hook
(lambda ()
(setq org-file-apps
'(("org" . emacs)
(org-file-apps '(("org" . emacs)
("rs" . emacs)
("c" . emacs)
("h" . emacs)
)))))
))
;; Define the right latexmk command to export to latex
(org-latex-pdf-process (list "latexmk -pdflatex='pdflatex -shell-escape -interaction nonstopmode' -output-directory=%o -pdf %f"))
;; Task management configuration
(org-log-done 'time)
(org-enforce-todo-dependencies t)
(org-enforce-todo-checkbox-dependencies t)
(org-todo-keywords '((sequence "TODO" "WAITING" "|" "DONE")))
;; where org mode can find its files for archiving and capture
(org-directory "~/documents/org")
(org-archive-location "~/documents/org/archive.org::* From %s")
(org-agenda-files (list "~/documents/org/index.org"
"~/.emacs.d/configuration.org"
"~/documents/org/work.org"
"~/documents/org/archive.org"))
;; Agenda
;; The week begin today
(org-agenda-start-on-weekday nil)
;; 15 days in agenda view
(org-agenda-span 15)
;;
;; Define a custom agenda view. I want my agenda with tasks that are scheduled or have a deadline,
;; but also all other tasks that do not have a date scheduled or as deadline. This is for tasks
;; that I will eventualy do later.
(org-agenda-custom-commands
'(("a" "Agenda"
(
(agenda "" ((org-agenda-skip-function '(org-agenda-skip-entry-if 'todo 'done))))
(alltodo "" ((org-agenda-skip-function '(org-agenda-skip-entry-if 'scheduled 'deadline 'todo 'done))))
))))
;; Define some capture template to be able to create tasks, or maybe
;; other things later
(org-capture-templates
'(("f" "Finished book"
table-line (file "~/Documents/org/books-read.org")
"| %^{Title} | %^{Author} | %u |")
("t" "Todo"
entry
(file+headline org-index-file "Tâches")
"* TODO %?\n:PROPERTIES:\nCREATED: %u\n:END:\n")
("b" "Bookmarks"
table-line (file "~/Documents/org/bookmarks.org")
"| %^{prompt|rust|other} | %^{url} | %^{what}")
("c" "Cycling"
table-line (file "~/Documents/org/cycling.org")
"| %t | balade | %^{prompt|standard|électrique} | %^{Distance} |")
("w" "Cycling to work"
table-line (file "~/Documents/org/cycling.org")
"| %t | boulot | %^{prompt|électrique|standard} | 26.2 |")))
:config
(add-to-list 'org-structure-template-alist
'("el" . "src emacs-lisp"))
(set-face-foreground 'org-verbatim "orange1")
;; Define a document class that do not use parts and start with chapters for latex export
)
#+END_SRC
Add a shortcut to toggle display of emphasis characters
......@@ -453,190 +519,21 @@ Vertico and Marginlia upgrades the minibuffer completion window by making it mor
(setq initial-major-mode 'org-mode)
#+end_src
And set some keyboard shortcuts for links and agenda
#+begin_src emacs-lisp
(global-set-key (kbd "C-c l") 'org-store-link)
(global-set-key (kbd "C-c a") 'org-agenda)
(global-set-key (kbd "C-c c") 'org-capture)
#+end_src
Add shortcuts to quickly add code blocks using =C-,=
#+begin_src emacs-lisp
(add-to-list 'org-structure-template-alist
'("el" . "src emacs-lisp"))
#+end_src
** Latex export
Use =latexmk= to export to Latex
#+begin_src emacs-lisp :exports code
(setq org-latex-pdf-process (list "latexmk -pdflatex='pdflatex -shell-escape -interaction nonstopmode' -output-directory=%o -pdf %f"))
#+end_src
Use =org-ref= for citation
#+begin_src emacs-lisp
(use-package org-ref)
(use-package org-ref
:bind ("C-c [" . 'org-reftex-citation)
)
(use-package org-ref-prettify)
#+end_src
And use the same shortcut for =org-reftex-citation= than for =reftex-citation=
#+begin_src emacs-lisp
(define-key org-mode-map (kbd "C-c [") 'org-reftex-citation)
#+end_src
Define a document class that do not use parts and start with chapters
#+begin_src emacs-lisp
(add-to-list 'org-latex-classes
'("book-noparts"
"\\documentclass{book}"
("\\chapter{%s}" . "\\chapter*{%s}")
("\\section{%s}" . "\\section*{%s}")
("\\subsection{%s}" . "\\subsection*{%s}")
("\\subsubsection{%s}" . "\\subsubsection*{%s}")
("\\paragraph{%s}" . "\\paragraph*{%s}")
("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
#+end_src
** Visuals
Use bullets instead of asterisks
#+begin_src emacs-lisp
(use-package org-bullets
:init
(add-hook 'org-mode-hook 'org-bullets-mode))
#+end_src
#+begin_src emacs-lisp
(set-face-foreground 'org-verbatim "orange1")
#+end_src
** Task management
Record when a todo item was marked as done and enforce marking
dependencies as done before being able to mark an item as done
#+begin_src emacs-lisp
(setq org-log-done 'time)
(setq org-enforce-todo-dependencies t)
(setq org-enforce-todo-checkbox-dependencies t)
#+end_src
Set default task completion states to =TODO=, =WAITING= and
=DONE=. I use =WAITING= when I can't go further on a task because
I'm waiting for some inputs.
#+begin_src emacs-lisp
(setq org-todo-keywords
'((sequence "TODO" "WAITING" "|" "DONE")))
#+end_src
*** index and archive files
Index and archive are my main todo lists (index) and a list of archived (done) tasks.
#+begin_src emacs-lisp
(setq org-directory "~/documents/org")
(defun org-file-path (filename)
"Return the absolute address of an org file, given its relative name."
(concat (file-name-as-directory org-directory) filename))
(setq org-index-file (org-file-path "index.org"))
(setq org-archive-location
(concat (org-file-path "archive.org") "::* From %s"))
#+end_src
Then more specifics org files to add to the agenda list
#+begin_src emacs-lisp
(setq org-agenda-files (list org-index-file
"~/.emacs.d/configuration.org"
(org-file-path "work.org")
(org-file-path "archive.org"))) ; Just in case I forget to mark a subtask as done and archive the main one
#+end_src
Hitting =C-c C-x C-s= will mark a todo as done and move it to an appropriate place in the archive.
#+begin_src emacs-lisp
(defun hrs/mark-done-and-archive ()
"Mark the state of an org-mode item as DONE and archive it."
(interactive)
(org-todo 'done)
(org-archive-subtree))
(define-key org-mode-map (kbd "C-c C-x C-s") 'hrs/mark-done-and-archive)
#+end_src
** Agenda
The week should begin today, not last Monday for the agenda view
#+begin_src emacs-lisp
(setq org-agenda-start-on-weekday nil)
#+end_src
I want to see more days in the agenda view
#+begin_src emacs-lisp
(setq org-agenda-span 15)
#+end_src
Define a custom agenda view. I want my agenda with tasks that are
scheduled or have a deadline, but also all other tasks that do not
have a date scheduled or as deadline. This is for tasks that I will
eventualy do later.
#+begin_src emacs-lisp
(setq org-agenda-custom-commands
'(("a" "Agenda"
(
(agenda "" ((org-agenda-skip-function '(org-agenda-skip-entry-if 'todo 'done))))
(alltodo "" ((org-agenda-skip-function '(org-agenda-skip-entry-if 'scheduled 'deadline 'todo 'done))))
))))
#+end_src
** Capture
Define some capture template to be able to create tasks, or maybe
other things later
#+begin_src emacs-lisp
(setq org-capture-templates
'(("f" "Finished book"
table-line (file "~/Documents/org/books-read.org")
"| %^{Title} | %^{Author} | %u |")
("t" "Todo"
entry
(file+headline org-index-file "Tâches")
"* TODO %?\n:PROPERTIES:\nCREATED: %u\n:END:\n")
("b" "Bookmarks"
table-line (file "~/Documents/org/bookmarks.org")
"| %^{prompt|rust|other} | %^{url} | %^{what}")
("c" "Cycling"
table-line (file "~/Documents/org/cycling.org")
"| %t | balade | %^{prompt|standard|électrique} | %^{Distance} |")
("w" "Cycling to work"
table-line (file "~/Documents/org/cycling.org")
"| %t | boulot | %^{prompt|électrique|standard} | 26.2 |")))
:hook org-mode
)
#+end_src
......@@ -646,8 +543,9 @@ Tree slide displays an org file as /slides/
#+begin_src emacs-lisp
(use-package org-tree-slide
:config
(define-key org-mode-map (kbd "<f8>") 'org-tree-slide-mode)
:bind (:map org-mode-map
("<f8>" . 'org-tree-slide-mode)
)
)
#+end_src
......@@ -659,9 +557,13 @@ Tree slide displays an org file as /slides/
#+begin_src emacs-lisp
;; Add Beamer to export list
(require 'ox-beamer)
(use-package ox-beamer
:ensure nil
)
;; And markdown
(require 'ox-md)
(use-package ox-md
:ensure nil
)
;; some HTML slide export engines
;; Don't really use them actually so commented out
......@@ -677,14 +579,28 @@ Tree slide displays an org file as /slides/
(use-package ox-pandoc)
#+end_src
Configure code highlighting using [[https://www.ctan.org/pkg/minted][minted]] (which uses
[[https://pygments.org/][Pygments]] as an external tool) for latex export
#+begin_src emacs-lisp
;; Configure ox-latex to export source block using minted
;; Setting minted cache to false as cache seems to fail when changing the output-directory
(use-package ox-latex
:ensure nil
:custom
(org-latex-listings 'minted)
:config
(add-to-list 'org-latex-classes
'("book-noparts"
"\\documentclass{book}"
("\\chapter{%s}" . "\\chapter*{%s}")
("\\section{%s}" . "\\section*{%s}")
("\\subsection{%s}" . "\\subsection*{%s}")
("\\subsubsection{%s}" . "\\subsubsection*{%s}")
("\\paragraph{%s}" . "\\paragraph*{%s}")
("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
(add-to-list 'org-latex-packages-alist '("cache=false" "minted"))
(setq org-latex-listings 'minted)
)
#+end_src
For HTML source code highlight, use =htmlize=
......@@ -697,7 +613,11 @@ Tree slide displays an org file as /slides/
Turn off validate link in org html export:
#+begin_src emacs-lisp
(setq org-html-validation-link nil)
(use-package ox-html
:ensure nil
:custom
(org-html-validation-link nil)
)
#+end_src
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment