scripts/assets/org/config.org

1898 lines
58 KiB
Org Mode
Executable File

#+TITLE: My Emacs Configuration
#+AUTHOR: TyKayn
#+EMAIL: contact@cipherbliss.com
#+OPTIONS: num:nil
* Ma config [[id:3adc0f02-729a-42fc-ae1f-7c29a1e5b11c][emacs]] - config.org
Voici la documentation au format Orgmode de ma configuration d'Emacs. Pour que cela fonctionne, il faut demander au fichier de config dans le dossier utilisateur, le fichier "~/.emacs" débutant par un point, de l'actuel fichier config.org.
J'utilise un dossier Nextcloud pour stocker mes textes, on retrouvera donc souvent des mentions à ce dossier dans la config. Ma liste de tâches [[file:tasks.org]] pour la gestion de projets se compose d'un fichier principal et de quelques autres.
Les réunions ont leur propre fichier, le journal aussi.
Fichiers souvent utiles:
- file:/home/tykayn/Nextcloud/textes/orgmode/tasks.org
- [[file:reunions.org]].
- [[file:journal.org]].
- [[id:d8636e1d-0137-4502-9384-767b41c892b0][boulot]]
- [[id:c1c19fdf-ccab-4d78-b191-dbe0f8c66609][lemonway]]
Contenu du fichier de config [[file:~/.emacs]]
#+begin_quote
;; -*- lexical-binding: t; -*-
;; The default is 800 kilobytes. Measured in bytes.
(setq gc-cons-threshold (* 50 1000 1000))
;; Profile emacs startup
(add-hook 'emacs-startup-hook
(lambda ()
(message "*** Emacs loaded in %s seconds with %d garbage collections."
(emacs-init-time "%.2f")
gcs-done)))
;; straight el bootstrap https://github.com/raxod502/straight.el#getting-started
(defvar bootstrap-version)
(let ((bootstrap-file
(expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
(bootstrap-version 5))
(unless (file-exists-p bootstrap-file)
(with-current-buffer
(url-retrieve-synchronously
"https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
'silent 'inhibit-cookies)
(goto-char (point-max))
(eval-print-last-sexp)))
(load bootstrap-file nil 'nomessage))
(straight-use-package 'use-package)
(setq straight-use-package-by-default t)
(use-package org)
(setq gnutls-algorithm-priority "NORMAL:-VERS-TLS1.3")
(set-default-coding-systems 'utf-8)
(org-babel-load-file "~/Nextcloud/textes/orgmode/config.org")
(server-start)
(global-set-key (kbd "<escape>") 'keyboard-escape-quit)
#+end_quote
* Introduction
Ma configuration d'Emacs. Voir la doc personnelle des concepts généraux d'[[id:3adc0f02-729a-42fc-ae1f-7c29a1e5b11c][emacs]] ici.
** Initialisation de cette configuration
Pour que cela fonctionne, il faut demander au fichier de config dans le dossier utilisateur, le fichier ".emacs" débutant par un point, de charger ce fichier **config.org**.
J'utilise un dossier Nextcloud pour stocker mes textes, on retrouvera donc souvent des mentions à ce dossier dans la config.
** Inspirations
- https://blog.sumtypeofway.com/posts/emacs-config.html
- http://doc.norang.ca/org-mode.html
- https://sachachua.com/dotemacs/index.html#org3dfd9e3
- https://github.com/alphapapa/unpackaged.el
- https://blog.sumtypeofway.com/posts/emacs-config.html
Plus sur mon blog:
https://www.cipherbliss.com
* Préconfiguration
#+begin_src emacs-lisp
;; -*- coding: utf-8; lexical-binding: t -*-
;; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - toujours s'assurer que les packages sont installés - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;; fait par tykayn le 7-04-2022
;; version GNU Emacs 28.2
#+end_src
** Gestion de paquets Straight.el
#+begin_src emacs-lisp
;; on utilise straight.el pour déclarer les packages à utiliser
#+end_src
** Charset UTF-8
#+begin_src emacs-lisp
#+end_src
* List packages
Adding Melpa
#+begin_src emacs-lisp
;; add melpa packages
(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
* Orgmode
** Global
#+begin_src emacs-lisp
;; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;; Org-Mode
; Things we can't set as defaults above, we can set here
(defun org-setup ()
(setq line-spacing 3)
(setq global-hl-line-mode nil)
(set-fringe-mode 0)
; Enable habit tracking (and a bunch of other modules)
;;; position the habit graph on the agenda to the right of the default
(setq org-habit-graph-column 50)
(setq header-line-format " ")
(setq org-ellipsis "⤵")
(setq org-catch-invisible-edits 'show-and-error)
(setq org-hide-emphasis-markers t)
(setq org-fontify-whole-heading-line t)
(setq org-tags-column 0)
(setq org-adapt-indentation t)
(setq org-deadline-warning-days 0)
(setq line-move-visual t)
;; Keep tasks with dates on the global todo lists
(setq org-agenda-todo-ignore-with-date nil)
;; Keep tasks with deadlines on the global todo lists
(setq org-agenda-todo-ignore-deadlines nil)
;; Keep tasks with scheduled dates on the global todo lists
(setq org-agenda-todo-ignore-scheduled nil)
;; Keep tasks with timestamps on the global todo lists
(setq org-agenda-todo-ignore-timestamp nil)
;; Remove completed deadline tasks from the agenda view
(setq org-agenda-skip-deadline-if-done t)
;; Remove completed scheduled tasks from the agenda view
(setq org-agenda-skip-scheduled-if-done t)
;; Remove completed items from search results
;; (setq org-agenda-skip-timestamp-if-done t)
;; Use sticky agenda's so they persist
(setq org-agenda-sticky t)
;; block tasks if child tasks are not done
(setq org-enforce-todo-dependencies t)
(setq org-cycle-separator-lines 0)
;; Enable display of the time grid so we can see the marker for the current time
(setq org-agenda-span 2)
(setq org-agenda-tags-column -100) ; take advantage of the screen width
(setq org-agenda-inhibit-startup t)
(setq org-agenda-use-tag-inheritance t)
(setq org-agenda-show-log t)
(setq org-agenda-skip-scheduled-if-done t)
(setq org-agenda-skip-deadline-if-done t)
(setq org-agenda-skip-deadline-prewarning-if-scheduled 'pre-scheduled)
(setq org-agenda-time-grid
'((daily today require-timed)
(800 1000 1200 1400 1600 1800 2000)
"......" "----------------"))
(setq org-columns-default-format "%14SCHEDULED %Effort{:} %1PRIORITY %TODO %50ITEM %TAGS")
;; Set default column view headings: Task Effort Clock_Summary
(setq org-columns-default-format "%80ITEM(Task) %10Effort(Effort){:} %10CLOCKSUM")
(setq
org-log-created 'time
org-log-done 'time
org-log-reschedule 'time
org-log-redeadline 'time
org-log-into-drawer t
org-log-refile 'time
))
(add-hook 'org-mode-hook #'org-setup)
;; click a link in the same frame when opening a file
(custom-set-variables
'(org-link-frame-setup
'((vm . vm-visit-folder-other-frame)
(vm-imap . vm-visit-imap-folder-other-frame)
(gnus . org-gnus-no-new-news)
(file . find-file)
(wl . wl-other-frame)))
'(git-gutter:visual-line t)
)
#+end_src
** Contextes d'agenda
#+begin_src emacs-lisp
(defvar my-org-agenda-contexts
'((tags-todo "phone")
(tags-todo "work")
(tags-todo "drawing")
(tags-todo "coding")
(tags-todo "writing")
(tags-todo "reading")
(tags-todo "computer")
(tags-todo "home")
(tags-todo "santé")
(tags-todo "errands"))
"Usual list of contexts.")
(setq org-agenda-sorting-strategy
'((agenda tag-up time-up priority-down category-keep)
;; (todo user-defined-up todo-state-up priority-down effort-up)
(todo todo-state-up priority-down effort-up)
(tags user-defined-up)
(search category-keep)))
(setq org-agenda-cmp-user-defined 'my-org-sort-agenda-items-user-defined)
(defun my-org-agenda-list-unscheduled (&rest ignore)
"Create agenda view for tasks that are unscheduled and not done."
(let* ((org-agenda-todo-ignore-with-date t)
(org-agenda-overriding-header "List of unscheduled tasks: "))
(org-agenda-get-todos)))
(setq org-stuck-projects
'("+PROJECT-MAYBE-DONE"
("TODO")
nil
"\\<IGNORE\\>"))
#+end_src
** Séquences de choses à faire
#+begin_src emacs-lisp
(setq org-todo-keywords
'((sequence
"SOMEDAY(.!)"
"TODO(t!)"
"NEXT(n!)"
"|"
"DONE(x!)" "CANCELLED(c!)")
(sequence
"TORELAUNCH(r@/!)" "TODELEGATE(-!)" "DELEGATED(d!)" "|" "DONE(1!)")))
#+end_src
** Vue d'agenda Orgmode
Présentation personnalisée d'agenda, "custom views".
#+begin_src emacs-lisp
;; Custom agenda command definitions --------------------------
;; https://orgmode.org/worg/org-tutorials/org-custom-agenda-commands.html
(use-package org-super-agenda)
(use-package org-ql)
(bind-key "<apps> a" 'org-agenda)
(setq org-return-follows-link t)
(setq org-cycle-include-plain-lists 'integrate)
(defun my-org-agenda-skip-scheduled ()
(org-agenda-skip-entry-if 'scheduled 'deadline 'regexp "\n]+>"))
(setq org-agenda-prefix-format
'((agenda . " %i %-12:c%?-12t% s")
(todo . " ")
(tags . " %i %-12:c")
(search . " %i %-12:c")))
(setq org-agenda-custom-commands
(quote (
;; ("s" "Super Agenda" agenda "FIXXME: does work but w/o super-agenda"
;; (org-super-agenda-mode)
;; (org-agenda nil "a"))
("c" "Classique Agenda et Todos"
((agenda "" ((org-agenda-span 2)))
(alltodo
""
((org-agenda-overriding-header "")
(org-super-agenda-groups
'((:name "Important, unscheduled"
:and (:priority "A"
:scheduled nil)
:order 2)
(:name "Inbox"
:file-path "Inbox.org"
:order 1)
(:name "Project-related, unscheduled"
:and (:tag "project" :date nil :todo ("STARTED" "WAITING" "TODO"))
:order 3)
(:name "Waiting"
:and (:todo "WAITING"
:scheduled nil)
:order 4)
(:discard (:todo "SOMEDAY"
:category "cooking"
:date t))
(:name "Unscheduled"
:scheduled nil
:order 5)
(:discard (:anything t))
)
)))
))
("x" "Unscheduled, untagged tasks" tags-todo "-someday-TODO=\"SOMEDAY\"-TODO=\"DELEGATED\"-TODO=\"WAITING\"-project-cooking-routine-evilplans-computer-writing-phone-sewing-home-errands-shopping"
((org-agenda-skip-function 'my-org-agenda-skip-scheduled)
(org-agenda-view-columns-initially nil)
(org-tags-exclude-from-inheritance '("project"))
(org-agenda-overriding-header "Unscheduled TODO entries: ")
(org-columns-default-format "%50ITEM %TODO %3PRIORITY %Effort{:} %TAGS")
(org-agenda-sorting-strategy '(todo-state-up priority-down effort-up tag-up category-keep))))
("b" "Boulot" tags-todo "+boulot")
("c" "Cancelled" tags-todo "CANCELLED")
("D" "Done tasks" tags-todo "DONE")
("i" "Inbox to sort" tags "+inbox")
("g". "GTD Searches") ;; category searches
("gd" "Daily"
agenda "" (
(org-agenda-overriding-header "\n-------------- Agenda du jour ------------------\n")
;; (org-agenda-todo-keyword-format "[ ]")
(org-agenda-span 1)
(tags-todo "+PRIORITY=\"A\"")
)
;; montrer aussi ce qui est dans l'inbox pour le trier
(tags-todo "+inbox")
)
("gw" "Weekly review"
agenda "" (
(org-agenda-overriding-header "\n-------------- Revue hebdomadaire\n------------------\n")
(org-agenda-start-day "-7d")
(org-agenda-span 7)
(org-agenda-start-on-weekday 1)
(org-agenda-start-with-log-mode '(closed))
(org-agenda-archives-mode t)
(org-agenda-todo-keyword-format "[X]")
(org-agenda-skip-function
'(org-agenda-skip-entry-if 'notregexp "^\\*\\* DONE ")
)
)
)
("g2" "Bi-weekly review" agenda "" ((org-agenda-span 14) (org-agenda-log-mode 1)))
("0" "Unestimated tasks" tags-todo "EFFORT=\"\"")
("5" "Quick tasks" tags-todo "EFFORT>=\"5\"&EFFORT<=\"15\"")
("8" "Medium tasks" tags-todo "EFFORT>=\"15\"&EFFORT<=\"60\"")
("9" "Unscheduled top 3 by context" my-org-agenda-contexts
((org-agenda-skip-function 'my-org-agenda-skip-scheduled)
(org-agenda-sorting-strategy '(priority-down effort-down))
(org-agenda-max-entries 3)))
("p" "By priority"
(
(tags-todo "+PRIORITY=\"A\"")
(tags-todo "+PRIORITY=\"B\"")
(tags-todo "+PRIORITY=\"\"")
(tags-todo "+PRIORITY=\"C\"")
)
((org-agenda-prefix-format "%-10c %-10T %e ")
(org-agenda-sorting-strategy '(priority-down tag-up category-keep effort-down))))
("P" "Printed paper agenda"
(
(agenda "" (
(org-agenda-span 7) ;; overview of appointments
(org-agenda-start-on-weekday nil) ;; calendar begins today
(org-agenda-repeating-timestamp-show-all t)
(org-agenda-entry-types '(:timestamp :sexp))
)
)
(agenda "" (
(org-agenda-span 1) ; daily agenda
(org-deadline-warning-days 7) ; 7 day advanced warning for deadlines
(org-agenda-todo-keyword-format "[ ]")
(org-agenda-scheduled-leaders '("" ""))
(org-agenda-prefix-format "%t%s")
)
)
(todo "TODO" ;; todos sorted by context
(
(org-agenda-prefix-format "[ ] %T: ")
(org-agenda-sorting-strategy '(tag-up priority-down))
(org-agenda-todo-keyword-format "")
(org-agenda-overriding-header "\nTasks by Context\n------------------\n")
)
)
)
((org-agenda-with-colors nil)
(org-agenda-compact-blocks t)
(org-agenda-remove-tags t)
(ps-number-of-columns 2)
(ps-landscape-mode t))
("~/agenda.ps"))
("f". "Filter Searches") ;; category searches
("fc" tags "+claire")
("fh" tags "+helia")
("fv" tags "+vovo")
("fs" tags "+social")
("n" "Non boulot" tags-todo "-boulot+TODO=TODO"
(todo "TODO"
((org-agenda-prefix-format "[ ] %T: ")
(org-agenda-overriding-header "Tâches pour le fun")
(org-agenda-sorting-strategy
'(todo-state-down effort-up category-keep)
))
)
)
("h" "Habits" tags-todo "STYLE=\"habit\""
((org-agenda-overriding-header "Habitudes")
(org-agenda-todo-keyword-format "[ ]")
(org-agenda-sorting-strategy
'(todo-state-down effort-up category-keep)))
)
)
)
)
#+end_src
** Ménage dans les tâches réalisées
#+begin_src emacs-lisp
(defun my-org-clean-up-inbox ()
"Archive all DONE tasks and sort the remainder by TODO order."
(interactive)
(with-current-buffer (find-file "~/Nextcloud/textes/orgmode/tasks.org")
(my-org-archive-done-tasks 'file)
(goto-char (point-min))
(if (org-at-heading-p) (save-excursion (insert "\n")))
(org-sort-entries nil ?p)
(goto-char (point-min))
(org-sort-entries nil ?o)
(save-buffer)))
(defun my-org-archive-done-tasks (&optional scope)
"Archive finished or cancelled tasks.
SCOPE can be 'file or 'tree."
(interactive)
(org-map-entries
(lambda ()
(org-archive-subtree)
(setq org-map-continue-from (outline-previous-heading)))
"TODO=\"DONE\"|TODO=\"CANCELLED\"" (or scope (if (org-before-first-heading-p) 'file 'tree))))
#+end_src
** Revue mensuelle (FIXME)
** Pimper les couleurs
#+begin_src emacs-lisp
;; pimp my agenda colors
(setq org-todo-keyword-faces
'(
("TODO" . org-warning)
("STARTED" . "yellow")
;; ("DONE" . (:foreground "#B4EB89") )
("WAITING" . (:foreground "red" :weight bold))
("SOMEDAY" . (:foreground "gray" :weight bold))
;; ("CANCELED" . (:foreground "#234" :weight bold))
)
)
#+end_src
** Définir l'effort sur une tâche
Raccourci pour définir un effort compté en nombre de minutes à consacrer à une tâche: F6.
#+begin_src emacs-lisp
;; org-set-effort
(global-set-key (kbd "<f6>") 'org-set-effort)
#+end_src
** Deadlines et Schedules
Cacher les avertissements de deadline les jours précédents pour ne pas encombrer l'agenda.
#+begin_src emacs-lisp
;; Hide the deadline prewarning prior to scheduled date.
;;(setq org-agenda-skip-deadline-prewarning-if-scheduled 'pre-scheduled)
(defun my-org-summarize-task-status ()
"Count number of tasks by status.
Probably should make this a dblock someday."
(interactive)
(let (result)
(org-map-entries
(lambda ()
(let ((todo (elt (org-heading-components) 2)))
(if todo
(if (assoc todo result)
(setcdr (assoc todo result)
(1+ (cdr (assoc todo result))))
(setq result (cons (cons todo 1) result)))))))
(message "%s" (mapconcat (lambda (x) (format "%s: %d" (car x) (cdr x)))
result "\n"))))
#+end_src
** Listes de tags
tags prédéfinis au choix lors de la qualification avec C-c C-q sur une tâche
#+begin_src emacs-lisp
(setq org-tag-alist '(
("adminsys" . ?A)
("administratif" . ?a)
("boulot" . ?b)
("dev" . ?d)
("email" .?e)
("GULL" . ?g)
("habitudes" . ?h)
("social" . ?s)
("tel" . ?t)
("osm" . ?o)
("inbox" . ?i)
("rangement" . ?r)
)
)
(setq org-todo-state-tags-triggers '(("CANCELLED" ("ARCHIVE" . t))))
#+end_src
** Template de capture
https://orgmode.org/manual/Template-expansion.html
La tâche à faire par défaut n'a pas de date prédéfinie et n'est pas actée comme étant vraiment un truc à réaliser, son mot clé d'action est donc SOMEDAY, un un truc à faire un jour peut être.
[[id:53ffed85-03d0-4fb2-90b5-af2ffbcc3a0d][méthode gtd]]
#+begin_src emacs-lisp
;; full screen captures
;; (add-hook 'org-capture-mode-hook 'delete-other-windows)
;;; templates de capture pour les nouvelles tâches
(setq org-capture-templates
'(
("t" "Todo someday"
entry (file+headline "~/Nextcloud/textes/orgmode/tasks.org" "Inbox")
"* SOMEDAY %? \n")
("d" "Todo this Day" entry (file+headline "~/Nextcloud/textes/orgmode/tasks.org" "Inbox")
"* TODO %?\nDEADLINE:%T \n")
("b" "Boulot" entry (file+headline "~/Nextcloud/textes/orgmode/boulot.org" "Inbox")
"* TODO %?\n :boulot:work: \n\n")
;; (file "~/Nextclod/textes/orgmode/org-roam/20220620110632-meeting_template.org")
("m" "Meeting" entry (file+datetree "~/Nextcloud/textes/orgmode/reunions.org" "Réunions")
"* Réunion %T - %U \n :[[id:d8636e1d-0137-4502-9384-767b41c892b0][boulot:meeting:]] \n\n**** Gens présents\n**** Notes\n - %?\n**** Choses à investiguer\n -\n**** Prochaines actions\n - Fin de la réunion: \n"
)
("e" "E-mail" entry (file+headline "~/Nextcloud/textes/orgmode/tasks.org" "Inbox")
"* TODO %? :mail:écriture: \n\n")
("n" "Next Task" entry (file+headline "~/Nextcloud/textes/orgmode/tasks.org" "Inbox")
"** NEXT %? \nDEADLINE: %t \n\n")
("p" "Phone call" entry (file+headline "~/Nextcloud/textes/orgmode/tasks.org" "Tel")
"* PHONE %? :tel:\n%U \n\n" :clock-in t :clock-resume t)
("j" "Journal" entry (file+datetree "~/Nextcloud/textes/orgmode/journal.org")
"* %?\nÉcrit le %U\n ")
;; ajouter une ligne dans un tableau
("v" "Table" table-line
(file+headline "~/Nextcloud/textes/orgmode/tasks.org" "Table")
"| %U | %? | auto-capture |")
)
)
;; raccourci custom pour clavier sans pavé numérique
(global-set-key (kbd "C-T") 'org-capture)
;; raccourci custom pour clavier sans pavé numérique
(global-set-key (kbd "C-T") 'org-capture)
#+end_src
** Org Roam, wiki personnel
https://systemcrafters.net/build-a-second-brain-in-emacs/capturing-notes-efficiently/
Raccourcis Org Roam généraux
#+begin_src emacs-lisp
(use-package org-roam
:init
(setq org-roam-v2-ack t)
:custom
(org-roam-capture-templates
'(("d" "default" plain
"%?"
:if-new (file+head "%<%Y%m%d%H%M%S>-${slug}.org" "#+title: ${title}\n\n* ${title}")
:unnarrowed t)
("m" "meeting" plain (file "~/Nextclod/textes/orgmode/org-roam/20220620110632-meeting_template.org")
:if-new (file+head "%<%Y%m%d%H%M%S>-meeting-${slug}.org" "#+title: ${title}\n")
:unnarrowed t
)
("b" "book notes" plain
"\n* Source\n\nAuthor: %^{Author}\nTitle: ${title}\nYear: %^{Year}\n\n* Summary\n\n%?"
:if-new (file+head "%<%Y%m%d%H%M%S>-${slug}.org" "#+title: ${title}\n")
:unnarrowed t))
)
:bind (
("C-c n l" . org-roam-buffer-toggle)
("C-c n f" . org-roam-node-find)
("C-c n i" . org-roam-node-insert)
("C-c n g" . org-roam-graph)
("C-c n t" . org-roam-tag-add)
("C-c n a" . org-roam-alias-add)
:map org-roam-dailies-map
("Y" . org-roam-dailies-capture-yesterday)
("T" . org-roam-dailies-capture-tomorrow)
)
:bind-keymap
("C-c n d" . org-roam-dailies-map)
:config
(require 'org-roam-dailies)
(org-roam-db-autosync-mode)
)
(setq org-roam-directory "~/Nextcloud/textes/orgmode/org-roam")
(setq org-roam-completion-everywhere t)
#+end_src
*** Roam graph
Graph naviguable des liens entre les notes Org Roam.
#+begin_src emacs-lisp
(use-package org-roam-ui
:straight
(:host github :repo "org-roam/org-roam-ui" :branch "main" :files ("*.el" "out"))
:after org-roam
;; normally we'd recommend hooking orui after org-roam, but since org-roam does not have
;; a hookable mode anymore, you're advised to pick something yourself
;; if you don't care about startup time, use
;; :hook (after-init . org-roam-ui-mode)
:config
(setq org-roam-ui-sync-theme t
org-roam-ui-follow t
org-roam-ui-update-on-save t
org-roam-ui-open-on-start t))
#+end_src
** Images incluses dans les fichiers org
#+begin_src emacs-lisp
(setq org-startup-with-inline-images t)
(global-set-key (kbd "M-<f12>") 'org-toggle-inline-images)
(global-set-key (kbd "C-M-<f12>") 'org-toggle-inline-images)
;; show details to edit links
(global-set-key (kbd "S-<f12>") 'visible-mode)
(global-set-key (kbd "C-S-<f12>") 'visible-mode)
#+end_src
** Refile des tâches
Ctrl + R
#+begin_src emacs-lisp
(global-set-key (kbd "C-R") 'org-refile)
#+end_src
** Liste de fichiers à considérer pour l'Agenda
:LOGBOOK:
- Refiled on [2022-11-06 dim. 18:36]
:END:
#+begin_src emacs-lisp
;; dossier des fichiers org à considérer pour les agendas, uniquement la racine du dossier orgmode dans Nextcloud
(setq org-agenda-files (list "~/Nextcloud/textes/orgmode"))
;; pouvoir faire du refile dans des headers de niveau 2 dans tasks.org
(setq org-refile-targets
'((nil :maxlevel . 1)
( "~/Nextcloud/textes/orgmode/tasks.org" :maxlevel . 3)))
#+end_src
** Macros pour lister et archiver les tâches finies
:LOGBOOK:
- Refiled on [2023-02-03 ven. 23:16]
:END:
#+begin_src emacs-lisp
;; voir la liste des tâches à l'état DONE
(fset 'done-tasks-list
(kmacro-lambda-form [?\C-c ?a ?t kp-4 ?r] 0 "%d"))
;; archiver les tâches à l'état DONE
(fset 'archive-done-tasks-list
(kmacro-lambda-form [?\C-c ?a ?t kp-4 ?r] 0 "%d"))
#+end_src
** Ajout de date de création d'une tâche
:LOGBOOK:
- Refiled on [2023-02-03 ven. 23:22]
- Refiled on [2023-01-08 dim. 10:10]
:END:
#+begin_src emacs-lisp
(defun insert-created-date(&rest ignore)
(org-back-to-heading) ; in org-capture, this folds the entry; when inserting a heading, this moves point back to the heading line
(move-end-of-line()) ; when inserting a heading, this moves point to the end of the line
(insert
(format-time-string
(concat " \n :PROPERTIES:\n:CREATED: [%F %T] \n:END:\n")
)
)
(org-back-to-heading)
(move-end-of-line())
)
; add to the org-capture hook
(add-hook
'org-capture-before-finalize-hook
#'insert-created-date
)
; hook it to adding headings with M-S-RET
; do not add this to org-insert-heading-hook, otherwise this also works in non-TODO items
;; and Org-mode has no org-insert-todo-heading-hook
;; désactivé
(advice-add 'org-insert-todo-heading :after #'insert-created-date)
#+end_src
* Raccourcis
** Retirer les mauvais raccourcis
#+begin_src emacs-lisp
;; remove bad shortcuts
(-map (lambda (x) (unbind-key x)) '(
"C-x C-b";; basic buffer list ibuffer
"C-x C-d" ;; list-directory
"C-z" ;; suspend-frame
"C-x C-z" ;; again
"M-o" ;; facemenu-mode
"<mouse-2>" ;; pasting with mouse-wheel click
"<C-wheel-down>" ;; text scale adjust
"<C-wheel-up>" ;; ditto
"s-n" ;; make-frame
"C-i" ;; tab ?
"C-x C-q" ;; read-only-mode
))
#+end_src
** Go to line
#+begin_src emacs-lisp
;; (global-set-key (kbd "C-G") 'goto-line)
#+end_src
** Lister les buffers avec Helm
#+begin_src emacs-lisp
(global-set-key (kbd "C-x C-b") 'helm-buffers-list)
#+end_src
** Commenter une ligne
Avec Ctrl+Shift+C
#+begin_src emacs-lisp
;; commenter une ligne de code, Ctrl Shift C.
(defun comment-eclipse ()
(interactive)
(let ((start (line-beginning-position))
(end (line-end-position)))
(when (or (not transient-mark-mode) (region-active-p))
(setq start (save-excursion
(goto-char (region-beginning))
(beginning-of-line)
(point))
end (save-excursion
(goto-char (region-end))
(end-of-line)
(point))))
(comment-or-uncomment-region start end)))
(global-set-key (kbd "C-S-c") 'comment-eclipse)
(global-set-key (kbd "C-s-c") 'comment-eclipse)
#+end_src
** Tout sélectionner
#+begin_src emacs-lisp
(global-set-key (kbd "C-a") 'mark-whole-buffer)
#+end_src
* Lecture
** Thème Doom nord
#+begin_src emacs-lisp
(use-package doom-themes
:config
;; Global settings (defaults)
(setq doom-themes-enable-bold t ; if nil, bold is universally disabled
doom-themes-enable-italic t) ; if nil, italics is universally disabled
;; thème principal https://github.com/doomemacs/themes
(load-theme 'doom-nord t)
;; Enable flashing mode-line on errors
(doom-themes-visual-bell-config)
;; Enable custom neotree theme (all-the-icons must be installed!)
(doom-themes-neotree-config)
;; or for treemacs users
(setq doom-themes-treemacs-theme "doom-atom") ; use "doom-colors" for less minimal icon theme
(doom-themes-treemacs-config)
;; Corrects (and improves) org-mode's native fontification.
(doom-themes-org-config))
(use-package doom-modeline
:config (doom-modeline-mode))
#+end_src
** Random note
Voir une note au hasard
https://github.com/mwfogleman/org-randomnote
#+begin_src emacs-lisp
(use-package org-randomnote
:ensure t
:bind ("C-c r" . org-randomnote))
(load-library "find-lisp")
(setq org-randomnote-candidates
(find-lisp-find-files "~/Nextcloud/textes/orgmode/org-roam" "\.org$"))
#+end_src
** Raccourcis d'agenda perso
#+begin_src emacs-lisp
;; - - - - - - - - - - - - - - - - - - - - - - - - - custom keys - - - - - - - - - - - - - - - - - - - - - - - - -
(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
** Tout
#+begin_src emacs-lisp
(setq left-margin-width 5)
(setq right-margin-width 5)
;; highlight of lines
(require 'hl-line)
(add-hook 'prog-mode-hook #'hl-line-mode)
(add-hook 'text-mode-hook #'hl-line-mode)
;; fonts
;; font for errors
(ignore-errors (set-frame-font "JuliaMono-12"))
;; alias
(defalias 'yes-or-no-p 'y-or-n-p)
;; - - - - - - - - - - - - - - - - - - - - - - - - - custom keys - - - - - - - - - - - - - - - - - - - - - - - - -
(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)
(defun switch-to-scratch-buffer ()
"Switch to the current session's scratch buffer."
(interactive)
(switch-to-buffer "*scratch*"))
(bind-key "C-c s" #'switch-to-scratch-buffer)
(global-set-key (kbd "C-x C-b") 'ibuffer)
(global-set-key (kbd "C-S-d") 'done-tasks-list)
(global-set-key (kbd "C-M-d") 'archive-done-tasks-list)
;; raccourcis issus d'habitudes de netbeans
;; save all by default Was: isearch-forward
(defun save-all () (interactive) (save-some-buffers t))
(global-set-key (kbd "C-x C-s") 'save-all)
(global-set-key (kbd "C-o") 'save-all)
(global-set-key (kbd "C-S-c") 'comment-line)
;; recherche dans tous les fichiers du dossier orgmode
(global-set-key (kbd "C-S-f") 'deft)
(global-set-key (kbd "<f1>") 'deft)
;; recherche dans le fichier courant avec ctrl + f
(global-set-key (kbd "C-f") 'isearch-forward)
(global-set-key (kbd "<f5>") 'org-capture)
(global-set-key (kbd "<f8>") 'org-cycle-agenda-files)
(global-set-key (kbd "<f12>") 'org-agenda)
(global-set-key (kbd "C-c <f9>") 'org-agenda-clock-goto)
(global-set-key (kbd "<f9>") 'org-clock-in)
(global-set-key (kbd "<f10>") 'org-clock-out)
(global-set-key (kbd "<f11>") 'org-clock-goto)
(global-set-key (kbd "<f2>") 'dir-treeview)
(global-set-key "\C-x\ \C-r" 'recentf-open-files)
(setq org-agenda-sticky t)
;; use org-bullets-mode for utf8 symbols as org bullets
(use-package org-bullets)
(require 'org-bullets)
;; make available "org-bullet-face" such that I can control the font size individually
(setq org-bullets-face-name (quote org-bullet-face))
(add-hook 'org-mode-hook (lambda () (org-bullets-mode 1)))
(setq org-bullets-bullet-list '("·" ""
""
""
""
""
""
))
;; org ellipsis options, other than the default Go to Node...
;; not supported in common font, but supported in Symbola (my fall-back font) ⬎, ⤷, ⤵
(setq org-ellipsis "");; ≫
;; make available "org-bullet-face" such that I can control the font size individually
(setq org-bullets-face-name (quote org-bullet-face))
;; détail de combinaison de touches
(use-package which-key
:diminish
:custom
(which-key-enable-extended-define-key t)
:config
(which-key-mode)
(which-key-setup-minibuffer))
(defun display-startup-echo-area-message ()
"Override the normally tedious startup message."
(message "Squalala!."))
#+end_src
* Syncronisation
** Auto revert les fichiers modifiés extérieurement
:LOGBOOK:
- Refiled on [2023-02-03 ven. 23:20]
- Refiled on [2023-02-03 ven. 23:13]
:END:
Résout les probl de syncro de [[id:bb81d7f9-cb33-495d-aea7-71ccf3bea2f2][workflow nextcloud]].
#+begin_src emacs-lisp
;; Revert Dired and other buffers
(setq global-auto-revert-non-file-buffers t)
;; Revert buffers when the underlying file has changed
(global-auto-revert-mode 1)
#+end_src
* Démarrage
** Barres d'outil cachées et choix de plein écran au démarrage
#+begin_src emacs-lisp
(menu-bar-mode 0)
(tool-bar-mode 0)
(scroll-bar-mode 0)
;; (add-to-list 'default-frame-alist '(fullscreen . maximized))
#+end_src
** Centrer la fenêtre
#+begin_src emacs-lisp
(use-package centered-window
:custom
(cwm-centered-window-width 120))
#+end_src
** Fichier par défaut à l'ouverture
Montrer la liste des tâches par défaut
#+begin_src emacs-lisp
(setq initial-buffer-choice "~/Nextcloud/textes/orgmode/config.org")
;; (setq initial-buffer-choice "~/Nextcloud/textes/orgmode/tasks.org")
#+end_src
** Voir le dashboard de tâches au démarrage
:LOGBOOK:
- Refiled on [2023-02-03 ven. 23:16]
:END:
#+begin_src emacs-lisp
;;---- open tasks list at startup
(setq initial-buffer-choice "~/Nextcloud/textes/orgmode/tasks.org")
#+end_src
* IDE et Code - Environnement de Développement Intégré
** Recherche globale
:LOGBOOK:
- Refiled on [2023-02-03 ven. 23:16]
:END:
Deft
#+begin_src emacs-lisp
(use-package deft)
(setq deft-directory "~/Nextcloud/textes/orgmode/")
(setq deft-recursive t)
(setq deft-use-filename-as-title t)
(setq deft-file-naming-rules
'((noslash . "-")
(nospace . "-")
(case-fn . downcase)))
#+end_src
** Mise en forme des parenthèses
:LOGBOOK:
- Refiled on [2023-02-03 ven. 23:16]
:END:
#+begin_src emacs-lisp
;; - - - - - - - - - - - - - - matching parentheses - - - - - - - - - - - - - - - - - - - - - - - - - -
(use-package paren
:ensure nil
:init
(setq show-paren-delay 0)
:config
(show-paren-mode +1))
(show-paren-mode)
(use-package rainbow-delimiters
:hook ((prog-mode . rainbow-delimiters-mode)))
;; dir tree
#+end_src
** Voir la liste des sélections copiées
:LOGBOOK:
- Refiled on [2023-02-03 ven. 23:16]
:END:
Afficher le kill-ring Ctrl+Shift+V
#+begin_src emacs-lisp
(global-set-key (kbd "C-S-v") 'helm-show-kill-ring)
#+end_src
** Calendar framework
:LOGBOOK:
- Refiled on [2023-02-03 ven. 23:18]
:END:
#+begin_src emacs-lisp
; calendar display
(use-package calfw)
(use-package calfw-org)
;; First day of the week
(setq calendar-week-start-day 0
calendar-day-name-array ["Dimanche" "Lundi" "Mardi" "Mercredi" "Jeudi" "Vendredi" "Samedi"]
calendar-month-name-array ["Janvier" "Février" "Mars" "Avril" "Mai"
"Juin" "Juillet" "Août" "Septembre"
"Octobre" "Novembre" "Décembre"]
calendar-date-style 'european
org-icalendar-timezone "Europe/Paris"
cfw:fchar-junction ?╋
cfw:fchar-vertical-line ?┃
cfw:fchar-horizontal-line ?━
cfw:fchar-left-junction ?┣
cfw:fchar-right-junction ?┫
cfw:fchar-top-junction ?┯
cfw:fchar-top-left-corner ?┏
cfw:fchar-top-right-corner ?┓
)
;; jour de début de semaine, 1 = Lundi.
(setq calendar-week-start-day 1)
;; agenda vue calendrier avec Ctrl super F12
(global-set-key (kbd "C-s-<f12>") 'cfw:open-org-calendar)
#+end_src
** Magit version Git
:LOGBOOK:
- Refiled on [2023-02-03 ven. 23:32]
:END:
#+begin_src emacs-lisp
(use-package magit)
;; see local log
(global-set-key (kbd "C-c m l ") 'magit-log:-L)
#+end_src
* Interface
** Heure dans la modeline
#+begin_src emacs-lisp
(display-time-mode 1)
#+end_src
** Common usage CUA
:LOGBOOK:
- Refiled on [2023-02-03 ven. 23:15]
:END:
#+begin_src emacs-lisp
;; raccourcis communs pour copier coller de texte
(cua-mode t)
;; couper toute la ligne, façon Nano editor, et façon PhpStorm
(global-set-key (kbd "C-K") 'kill-whole-line)
(global-set-key (kbd "C-E") 'kill-whole-line)
;; rechercher et remplacer
(global-set-key (kbd "C-S-H") 'query-replace)
#+end_src
** Changer la taille de font
:LOGBOOK:
- Refiled on [2023-02-03 ven. 23:16]
:END:
Ctrl + et Ctrl -
#+begin_src emacs-lisp
(global-set-key (kbd "C-+") 'text-scale-increase)
(global-set-key (kbd "C--") 'text-scale-decrease)
#+end_src
** Font Custom et mode de ligne
:LOGBOOK:
- Refiled on [2023-02-03 ven. 23:16]
:END:
#+begin_src emacs-lisp
(add-hook 'org-mode-hook 'variable-pitch-mode)
(add-hook 'org-mode-hook 'visual-line-mode)
(add-hook 'org-mode-hook 'prettify-symbols-mode)
(defun my-org-config/setup-buffer-face ()
(setq buffer-face-mode-face '(:family "Calibri"))
(buffer-face-mode)
)
(custom-set-faces
'(org-level-1 ((t (:inherit outline-1 :height 2.0))))
'(org-level-2 ((t (:inherit outline-2 :height 1.750))))
'(org-level-3 ((t (:inherit outline-3 :height 1.5))))
'(org-level-4 ((t (:inherit outline-4 :height 1.25))))
'(org-level-5 ((t (:inherit outline-5 :height 1.0))))
)
#+end_src
** Custom GUI sans barres
:LOGBOOK:
- Refiled on [2023-02-03 ven. 23:17]
:END:
Désactivez ceci si vous êtes débutant.
#+begin_src emacs-lisp
;; barres de GUI
(setq tool-bar-mode t)
(setq scroll-bar-mode t)
(setq menu-bar-mode t)
#+end_src
** Icones
:LOGBOOK:
- Refiled on [2023-02-03 ven. 23:17]
:END:
#+begin_src emacs-lisp
;; - - - - - - - - - - - - - - icons - - - - - - - - - - - - - - - - - - - - - - - - - -
(use-package all-the-icons)
(require 'all-the-icons)
(use-package all-the-icons-dired
:after all-the-icons
:hook (dired-mode . all-the-icons-dired-mode))
#+end_src
** Fenêtres, buffers
:LOGBOOK:
- Refiled on [2023-02-03 ven. 23:17]
:END:
Fermer tous les buffers.
#+begin_src emacs-lisp
(defun kill-all-buffers ()
"Close all buffers."
(interactive)
(let ((lsp-restart 'ignore))
;; (maybe-unset-buffer-modified)
(delete-other-windows)
(save-some-buffers)
(let
((kill-buffer-query-functions '()))
(mapc 'kill-buffer (buffer-list)))))
(bind-key "C-c K" #'kill-all-buffers)
(bind-key "C-x !" #'delete-other-windows) ;; Access to the old keybinding.
#+end_src
* Traduction - Fr
Locale des dates en Fr
#+begin_src emacs-lisp
;; localise dates
;; https://www.emacswiki.org/emacs/CalendarLocalization#h5o-11
(setq org-agenda-span 7
org-agenda-start-on-weekday 1
european-calendar-style t
display-time-24hr-format t
display-time-day-and-date t
calendar-day-abbrev-array ["dim" "lun" "mar" "mer" "jeu" "ven" "sam"]
calendar-day-name-array ["Dimanche" "Lundi" "Mardi" "Mercredi"
"Jeudi" "Vendredi" "Samedi"]
calendar-month-abbrev-array ["jan" "fév" "mar" "avr" "mai" "jun" "jul" "aou" "sep" "oct" "nov" "déc"]
calendar-month-name-array ["Janvier" "Février" "Mars" "Avril" "Mai"
"Juin" "Juillet" "Août" "Septembre"
"Octobre" "Novembre" "Décembre"]
org-agenda-start-day "-0d"
org-hierarchical-todo-statistics nil ;; count all TODO as checkboxes
org-scheduled-delay-days 1
org-cycle-separator-lines 0
)
#+end_src
* Sauvegarde et historique
** Sauvegarde à la perte de focus
#+begin_src emacs-lisp
;; sauvegarder les frames quand on change de focus
(defun save-all ()
(interactive)
(org-update-all-dblocks)
(save-some-buffers t))
(add-hook 'focus-out-hook 'save-all)
#+end_src
* Développement
#+begin_src emacs-lisp
#+end_src
** Gestion de version
#+begin_src emacs-lisp
;; https://github.com/emacsorphanage/git-gutter
(use-package git-gutter)
(global-git-gutter-mode +1)
#+end_src
** Auto format
#+begin_src emacs-lisp
;; (setq org-adapt-indentation t)
;; *** Auto Indent
(defun indent-org-block-automatically ()
(when (org-in-src-block-p)
(org-edit-special)
(indent-region (point-min) (point-max))
(org-edit-src-exit))
)
(global-set-key (kbd "C-S-f") 'indent-org-block-automatically)
#+end_src
** Tab avec largeur de 2 espaces
#+begin_src emacs-lisp
(setq-default tab-width 2)
#+end_src
** Dupliquer la ligne
#+begin_src emacs-lisp
;; --- dupliquer la sélection
(use-package duplicate-thing
:init
(defun pt/duplicate-thing ()
"Duplicate thing at point without changing the mark."
(interactive)
(save-mark-and-excursion (duplicate-thing 1))
(call-interactively #'next-line))
:bind ("C-d" . pt/duplicate-thing)
)
#+end_src
** Ne pas montrer de messages au démarrage
#+begin_src emacs-lisp
;; hide some annoyances
(defun do-nothing (interactive))
(defalias 'view-emacs-news 'do-nothing)
(defalias 'describe-gnu-project 'do-nothing)
(setq user-full-name "TyKayn"
user-mail-address "contact@cipherbliss.com")
#+end_src
** Markdown
#+begin_src emacs-lisp
(use-package markdown-mode
:mode ("\\.\\(njk\\|md\\)\\'" . markdown-mode))
#+end_src
** Json
#+begin_src emacs-lisp
(use-package json-mode)
#+end_src
** Sauvegardes des fichiers
#+begin_src emacs-lisp
(setq backup-directory-alist '(("." . "~/.config/emacs/backups")))
#+end_src
* Écriture
** Centrer le texte - Olivetti
#+begin_src emacs-lisp
;; olivetti
;; Distraction-free screen
(use-package olivetti
:straight t
:init
(setq
olivetti-body-width 85
text-scale-increase 1.15
olivetti-mode t
)
:config
)
;; change font size on load of text files
(
add-hook 'org-mode-hook
(lambda ()
(interactive)
(message "Olivetti text-mode-hook")
;; (olivetti-set-width .75)
;; (hidden-mode-line-mode)
(olivetti-mode 1)
)
)
;; focus on text in fullscreen
(use-package writeroom-mode)
#+end_src
** Auto complétion
#+begin_src emacs-lisp
;; Auto completion
(use-package company
:config
(setq company-idle-delay 0.15
company-minimum-prefix-length 4
company-selection-wrap-around t))
(global-company-mode)
;; Helm configuration
(use-package helm
:config
(require 'helm-config)
:init
(helm-mode 1)
:bind
(("M-x" . helm-M-x) ;; Evaluate functions
("C-x C-f" . helm-find-files) ;; Open or create files
("C-x b" . helm-mini) ;; Select buffers
("C-x C-r" . helm-recentf) ;; Select recently saved files
("C-c i" . helm-imenu) ;; Select document heading
("M-y" . helm-show-kill-ring) ;; Show the kill ring
:map helm-map
;; ("C-z" . helm-select-action)
;; ("<tab>" . helm-execute-persistent-action)
) )
#+end_src
** Abbréviations
:LOGBOOK:
- Refiled on [2023-01-05 jeu. 14:17]
:END:
#+begin_src emacs-lisp
(add-hook 'text-mode-hook #'abbrev-mode)
(define-abbrev-table 'global-abbrev-table '(
("afaict" "as far as I can tell" nil 0)
("poru" "pour" nil 0)
("sdep" "soit dit en passant" nil 0)
("jspcs" "j'en suis pas complètement sûr" nil 0)
("psa" "pas" nil 0)
("aç" "ça" nil 0)
("osmm" "OpenStreetMap" nil 0)
("cb" "CipherBliss" nil 0)
("tyk" "TyKayn" nil 0)
("omuse" "http://www.emacswiki.org/cgi-bin/oddmuse.pl" nil 0)
("btw" "by the way" nil 0)
("wether" "whether" nil 0)
("ewiki" "http://www.emacswiki.org/cgi-bin/wiki.pl" nil 0)
("pov" "point of view" nil 1)
))
#+end_src
** Rangement Org
:LOGBOOK:
- Refiled on [2023-01-10 mar. 08:40]
:END:
Ranger les headers ou tâches par alphabet, priorité, etc.
#+begin_src emacs-lisp
;; rangement des headers et tâches
(global-set-key (kbd "C-c C-ç") 'org-sort)
#+end_src
** Tabulations
:LOGBOOK:
- Refiled on [2023-02-03 ven. 23:13]
- Refiled on [2023-01-05 jeu. 13:54]
:END:
#+begin_src emacs-lisp
(setq-default tab-width 2)
#+end_src
** Insérer la date et l'heure
:LOGBOOK:
- Refiled on [2023-02-03 ven. 23:15]
:END:
raccourci: *Ctrl c, !*
*Ctrl U Ctrl C .
exemple : <2022-06-27 lun. 18:51>
#+begin_src emacs-lisp
(defvar bjk-timestamp-format "<%Y-%m-%d %H:%M>"
"Format of date to insert with `bjk-timestamp' function
%Y-%m-%d %H:%M will produce something of the form YYYY-MM-DD HH:MM
Do C-h f on `format-time-string' for more info")
(defun bjk-timestamp ()
"Insert a timestamp at the current point.
Note no attempt to go to beginning of line and no added carriage return.
Uses `bjk-timestamp-format' for formatting the date/time."
(interactive)
(insert (org-format-time-string bjk-timestamp-format (current-time)))
)
;; insérer timestamp date et heure
(global-set-key "\C-c !" 'insert-current-date-time)
#+end_src
** cliplink
:LOGBOOK:
- Refiled on [2023-02-03 ven. 23:23]
:END:
coller un lien formaté avec son titre
#+begin_src emacs-lisp
(use-package org-cliplink)
(require 'org-cliplink)
(global-set-key (kbd "C-x C-v") 'org-cliplink)
#+end_src
* Exports
** Export en JSON
Pour la création d'une page de rapport d'activités en HTML.
[[id:ac712d1c-5141-45dc-9647-46e61a835b01][stats orgmode]]
#+begin_src emacs-lisp
(use-package ox-json)
(require 'ox-json)
#+end_src
** Résoudre les liens Roam manquants aux exports org
:LOGBOOK:
- Refiled on [2023-02-03 ven. 23:13]
:END:
[[https://github.com/kaushalmodi/ox-hugo/issues/483#issuecomment-1003301339][kaushalmodi/ox-hugo#483 Unable to resolve link when exporting org file with r...]]
#+begin_src emacs-lisp
(setq org-id-extra-files (find-lisp-find-files org-roam-directory "\.org$"))
#+end_src
** Exporter vers HTML avec un style commun
:LOGBOOK:
- Refiled on [2023-02-03 ven. 23:21]
:END:
Toujours insérer en style inline un fichier css lors des exports en html.
#+begin_quote
C-c C-e
#+end_quote
#+begin_src emacs-lisp
;; exporter sans nombres ajoutés dans les titres de section
(setq org-export-with-section-numbers nil)
;; export with default modern css
(defun my-org-inline-css-hook (exporter)
"Insert custom inline css"
(when (eq exporter 'html)
(let* ((dir (ignore-errors (file-name-directory (buffer-file-name))))
(path (concat dir "style.css"))
(homestyle (or (null dir) (null (file-exists-p path))))
(final (if homestyle "~/Nextcloud/textes/orgmode/style.css" path))) ;; <- set your own style file path
(setq org-html-head-include-default-style nil)
(setq org-html-head (concat
"<style type=\"text/css\">\n"
"<!--/*--><![CDATA[/*><!--*/\n"
(with-temp-buffer
(insert-file-contents final)
(buffer-string))
"/*]]>*/-->\n"
"</style>\n"))
)))
(add-hook 'org-export-before-processing-hook 'my-org-inline-css-hook)
#+end_src
*** Présentation reveal js
Pour faire une présentation en slides html avec Reveal JS
#+begin_src emacs-lisp
(straight-use-package '(ox-reveal :host github
:repo "yjwen/org-reveal"
:branch "master"))
(setq org-reveal-root "file:///home/tykayn/Nextcloud/textes/orgmode/reveal.js")
(require 'ox-reveal)
#+end_src
* À suivre
La suite est à inventer.
Pour installer cette configuration d'emacs, lancez le script qui se trouve ici https://forge.chapril.org/tykayn/scripts/src/branch/master/install_emacs_tk.sh
#+begin_src bash
wget https://forge.chapril.org/tykayn/scripts/raw/branch/master/install_emacs_tk.sh | bash
#+end_src
* Désactivées
Les configurations qui fonctionnenemt mais ont été désactivées
** Recompter les cookies à la sauvegarde et mettre en DONE automatiquement [désactivé]
:LOGBOOK:
- Refiled on [2023-01-08 dim. 10:10]
- Refiled on [2022-11-18 ven. 23:35]
:END:
#+begin_src emacs-lisp
(defun org-summary-todo (n-done n-not-done)
"Switch entry to DONE when all subentries are done, to TODO otherwise."
(let (org-log-done org-log-states) ; turn off logging
(org-todo (if (= n-not-done 0) "DONE" "TODO"))))
;; (add-hook 'org-after-todo-statistics-hook #'org-summary-todo)
#+end_src
** Clean des espaces [désactivé]
:LOGBOOK:
- Refiled on [2023-01-08 dim. 10:10]
- Refiled on [2023-01-05 jeu. 13:54]
:END:
#+begin_src bash
apt-get install elpa-ws-butler
#+end_src
#+begin_src emacs-lisp
;; (setq ws-butler-trim-predicate
;; (lambda (beg end)
;; (not (eq 'font-lock-string-face
;; (get-text-property end 'face)))))
;; (require 'ws-butler)
;; (add-hook 'prog-mode-hook #'ws-butler-mode)
#+end_src
* WIP - configuration non testées
** Mastodon post
#+begin_src emacs-lisp
#+end_src
** copier coller d'images
https://www.orgroam.com/manual.html#Full_002dtext-search-with-Deft
#+begin_src emacs-lisp
(use-package org-download
:after org
:bind
(:map org-mode-map
(("s-Y" . org-download-screenshot)
("s-y" . org-download-yank))))
#+end_src
** Modernité de l'éditeur
basé sur le fichier de conf de Jax Dixit
#+begin_src emacs-lisp
(delete-selection-mode t)
;; (global-display-line-numbers-mode t)
(column-number-mode)
(setq
;; Double-spaces after periods is morally wrong.
sentence-end-double-space nil
;; scroll to first error
compilation-scroll-output 'first-error
;; Never ding at me, ever.
ring-bell-function 'ignore
fast-but-imprecise-scrolling t
;; prefer newer elisp files
load-prefer-newer t
;; when I say to quit, I mean quit
confirm-kill-processes nil
;; if native-comp is having trouble, there's not very much I can do
native-comp-async-report-warnings-errors 'silent
;; unicode ellipses are better
truncate-string-ellipsis "…"
)
(electric-pair-mode)
(setq require-final-newline t)
;; recherche dans un projet
(use-package deadgrep
:bind (("C-c C-h" . #'deadgrep)))
#+end_src
** Bibliographie
C-c C-b pour ajouter une bibliothraphie.
#+begin_src emacs-lisp
;; BibLaTeX settings
;; bibtex-mode
#+end_src
https://lucidmanager.org/productivity/emacs-bibtex-mode/
*** Références bibliographiques
#+begin_src emacs-lisp
;; BibLaTeX settings
#+end_src
** Projectile, gestion de projets
#+begin_src emacs-lisp
;; non pris en compte pour l'ajout d'une deadline ou schedule
;; (use-package projectile)
;; (projectile-mode +1)
;; (define-key projectile-mode-map (kbd "s-p") 'projectile-command-map)
;; (define-key projectile-mode-map (kbd "C-c p") 'projectile-command-map)
#+end_src
** Ajout de majuscule aux entêtes (FIXME)
:LOGBOOK:
- Refiled on [2022-11-04 ven. 00:30]
:END:
#+begin_src emacs-lisp
;; (defun org-auto-capitalize-headings-and-lists ()
"Create a buffer-local binding of sentence-end to auto-capitalize
section headings and list items."
;; (make-local-variable 'sentence-end)
;; (setq sentence-end (concat (rx (or
;; ;; headings
;; (seq line-start (1+ "*") (1+ space))
;; ;; list and checklist items
;; (seq line-start (0+ space) "-" (1+ space) (? (or "[ ]" "[X]") (1+ space)))))
;; "\\|" (sentence-end))))
;; ;; (add-hook 'org-mode-hook #'org-auto-capitalize-headings-and-lists)
#+end_src
** Traduction du mini agenda FIXME
:LOGBOOK:
- Refiled on [2022-11-04 ven. 00:32]
:END:
** Auto refresh d'agenda FIXME
Actuellement réalisé avec un cronjob qui lance un script bash.
:LOGBOOK:
- Refiled on [2022-11-04 ven. 00:34]
:END:
Toutes les 5 minutes, auto rafraîchir l'agenda si il est présent.
https://orgmode.org/worg/org-hacks.html#orga494948
#+begin_src emacs-lisp
#+end_src
** Ménage dans les fichiers
:LOGBOOK:
- Refiled on [2022-11-04 ven. 00:35]
:END:
*** Enlever les propriétés vides FIXME
*** Enlever les tags redondants avec leur Header FIXME
** publication de site web du wiki FIXME
:LOGBOOK:
- Refiled on [2022-11-04 ven. 00:36]
:END:
Ox-Hugo https://ox-hugo.scripter.co/doc/installation/
#+begin_src emacs-lisp
;; ----- hugo export to publish website
;; (use-package ox-hugo
;; :straight t ;Auto-install the package from Melpa
;; :pin melpa ;`package-archives' should already have ("melpa" . "https://melpa.org/packages/")
;; :after ox)
;; (setq org-hugo-base-dir "~/Nextcloud/textes/hugo")
;; (with-eval-after-load 'ox
;; (require 'ox-hugo))
;; (require 'ox-hugo)
#+end_src
** Faire un log de toutes les commandes réalisées en live (FIXME)
** Frame suivante et précédente
#+begin_src emacs-lisp
(global-set-key (kbd "M-<right>") 'next-buffer)
(global-set-key (kbd "M-<left>") 'previous-buffer)
#+end_src
** UTF 8
:LOGBOOK:
- Refiled on [2022-11-06 dim. 18:37]
:END:
#+begin_src emacs-lisp
(set-charset-priority 'unicode)
(prefer-coding-system 'utf-8-unix)
#+end_src
** Supprimer les espaces de fin
:LOGBOOK:
- Refiled on [2022-11-06 dim. 18:43]
:END:
#+begin_src emacs-lisp
(add-hook 'before-save-hook #'delete-trailing-whitespace)
;; (setq require-final-newline t)
(defalias 'view-emacs-news 'ignore)
(defalias 'describe-gnu-project 'ignore)
(setq mouse-wheel-tilt-scroll t
mouse-wheel-flip-direction t)
(setq-default truncate-lines t)
#+end_src
** Dired - vue des dossiers et fichiers dans Emacs
#+begin_src emacs-lisp
(global-set-key (kbd "C-x C-d") 'dired)
(global-set-key (kbd "C-x C-j") 'dired-jump)
;; Open dired folders in same buffer
(put 'dired-find-alternate-file 'disabled nil)
;; Sort Dired buffers
(setq dired-listing-switches "-agho --group-directories-first")
;; Move deleted files to trash
(setq delete-by-moving-to-trash t)
#+end_src
*** Filetags [[id:aa8865c0-53d7-444f-9119-4cfce73c27d1][tags sur noms de fichiers]] dans Dired
Demande l'installation du paquet pip3 filetags
#+begin_src emacs-lisp
(defun my-dired-filetags ()
"Run \"filetags\" on current or marked files"
(interactive)
(let* ((marked-files (f-uniquify (dired-get-marked-files)))) ;; apply to single file or marked files
;; --disable-server → provides a blocking terminal window (instead of a non-blocking one which swallows the revert-buffer afterward)
(dired-do-shell-command "xfce4-terminal --disable-server --geometry=100x20+330+5 --hide-menubar -x ~/.local/bin/filetags --interactive *" nil marked-files)
)
(revert-buffer nil t t) ;; refresh listing of files
)
(define-key dired-mode-map (kbd "M-t") 'my-dired-filetags)
#+end_src
** Best default settings
[[https://systemcrafters.net/emacs-from-scratch/the-best-default-settings][The 6 Emacs Settings Every User Should Consider - System Crafters]]
#+begin_src emacs-lisp
;; Revert buffers when the underlying file has changed
(global-auto-revert-mode 1)
;; Revert Dired and other buffers
(setq global-auto-revert-non-file-buffers t)
;; remember the files you edited most recently
(recentf-mode 1)
;; Save what you enter into minibuffer prompts
(setq history-length 25)
(savehist-mode 1)
;; Remember and restore the last cursor location of opened files
(save-place-mode 1)
;; Don't pop up UI dialogs when prompting
(setq use-dialog-box nil)
#+end_src
** Dossiers dirvish
:LOGBOOK:
- Refiled on [2023-02-03 ven. 23:18]
:END:
#+begin_src emacs-lisp
;; (use-package dirvish
;; :init
;; ;; Let Dirvish take over Dired globally
;; (dirvish-override-dired-mode)
;; )
;; (require 'dirvish)
#+end_src
*** Accès aux fichiers courants
:LOGBOOK:
- Refiled on [2023-02-03 ven. 23:16]
:END:
**** Accéder à la config
#+begin_src emacs-lisp
(defun tk/switch-to-config-buffer ()
"Switch to the current session's tasks.org buffer."
(interactive)
(switch-to-buffer "config.org"))
(global-set-key (kbd "C-x c o") 'tk/switch-to-config-buffer)
#+end_src
**** Accéder aux tâches
#+begin_src emacs-lisp
(defun tk/switch-to-tasks-buffer ()
"Switch to the current session's tasks.org buffer."
(interactive)
(switch-to-buffer "tasks.org"))
(global-set-key (kbd "C-x C-t") 'tk/switch-to-tasks-buffer)
#+end_src
**** Fichiers récents
#+begin_src emacs-lisp
;; see recent files
(use-package recentf
:config
(add-to-list 'recentf-exclude "\\elpa")
(add-to-list 'recentf-exclude "private/tmp")
(recentf-mode))
;; recent files
(setq recentf-max-menu-items 25)
(setq recentf-max-saved-items 25)
#+end_src
** Export d'un site web hugo
:LOGBOOK:
- Refiled on [2023-02-03 ven. 23:22]
- Refiled on [2023-02-03 ven. 23:14]
:END:
[[id:8e60dc99-ae78-4f57-8bed-d054640d6b61][orgroam]]
http://blog.sidhartharya.com/exporting-org-roam-notes-to-hugo/
#+begin_src emacs-lisp
(use-package ox-hugo
:ensure t ;Auto-install the package from Melpa
:pin melpa ;`package-archives' should already have ("melpa" . "https://melpa.org/packages/")
:after ox)
(defun org-hugo--tag-processing-fn-roam-tags(tag-list info)
"Process org roam tags for org hugo"
(if (org-roam--org-roam-file-p)
(append tag-list
'("braindump")
(mapcar #'downcase (org-roam--extract-tags)))
(mapcar #'downcase tag-list)
))
(add-to-list 'org-hugo-tag-processing-functions 'org-hugo--tag-processing-fn-roam-tags)
;; backlinks
(defun org-hugo--org-roam-backlinks (backend)
(when (equal backend 'hugo)
(when (org-roam--org-roam-file-p)
(beginning-of-buffer)
(replace-string "{" "")
(beginning-of-buffer)
(replace-string "}" "")
(end-of-buffer)
(org-roam-buffer--insert-backlinks))))
(add-hook 'org-export-before-processing-hook #'org-hugo--org-roam-backlinks)
#+end_src
** Template vierge
#+begin_src emacs-lisp
#+end_src
* Have fun!
merci!
https://cipherbliss.com
- TyKayn