:PROPERTIES:
:ID:       e67fd24d-6988-4c95-935e-c8604810212b
:END:
#+title: Emacs
#+property: header-args :tangle ~/.emacs.d/config.el

* DONE early-init.el

For straight.el to pick up before package.el

#+begin_src elisp :tangle ~/.emacs.d/early-init.el
  (setq package-enable-at-startup nil)
#+end_src

* DONE [7/7] .emacs
:LOGBOOK:
- State "DONE"       from "DONE"       [2024-07-19 Fri 16:07]
- State "DONE"       from "DONE"       [2024-07-19 Fri 16:07]
- State "DONE"       from "DONE"       [2024-07-19 Fri 14:40]
- State "DONE"       from "DONE"       [2024-07-19 Fri 14:40]
- State "DONE"       from "DONE"       [2024-07-09 Tue 12:11]
- State "DONE"       from "TODO"       [2023-07-02 Sun 15:02]
:END:
**** DONE Front matter

#+begin_src elisp :tangle ~/.emacs
  ;;; .emacs --- Global settings
  ;;; Commentary:
  ;;; Code:

  ;; -*- lexical-binding: t; -*-
#+end_src

**** DONE Garbage collector - increase threshold to 500 MB to ease startup

#+begin_src elisp :tangle ~/.emacs
  (setq gc-cons-threshold (* 500 1024 1024))
#+end_src

**** DONE [3/3] Package.el
***** DONE List package archives and initialize them (package.el)

#+begin_src elisp :tangle no
  (require 'package)
  (setq package-archives '(
    			 ("gnu" . "https://elpa.gnu.org/packages/")
    			 ("melpa" . "https://melpa.org/packages/")
    			 ("nongnu" . "https://elpa.nongnu.org/nongnu/")
    			 )
        )
  (setq package-install-upgrade-built-in t)
  (setq package-check-signature "allow-unsigned")
  (gnu-elpa-keyring-update)		
  (package-initialize)
  (package-refresh-contents)
#+end_src

***** DONE Install use-package (package.el)

#+begin_src elisp :tangle no
  (unless (package-installed-p 'use-package)
    (package-refresh-contents)
    (package-install 'use-package)
    )

  (eval-when-compile  (require 'use-package)) ;; allow byte-compile while using use-package
#+end_src

***** DONE Make sure Org is installed (package.el)

#+begin_src elisp :tangle no
  (unless (package-installed-p 'org)
    (package-install 'org)
    )
#+end_src

**** DONE [3/3] Straight.el
***** DONE Bootstrap Straight.el and install use-package

#+begin_src elisp :tangle ~/.emacs
  (setq straight-repository-branch "develop") ;; Using develop branch temporarily to fix the org-roam-dailies issue. From https://github.com/org-roam/org-roam/issues/2361#issuecomment-1671601796

  (eval-and-compile
    (defvar bootstrap-version)
    (let ((bootstrap-file
           (expand-file-name "straight/repos/straight.el/bootstrap.el"
              		   (or (bound-and-true-p straight-base-dir)
              		       user-emacs-directory)))
          (bootstrap-version 7))
      (unless (file-exists-p bootstrap-file)
        (with-current-buffer
            (url-retrieve-synchronously  "https://raw.githubusercontent.com/radian-software/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)
    )
#+end_src

***** DONE Integrate use-package and straight
#+begin_src elisp :tangle ~/.emacs
  (setq straight-use-package-by-default t)
#+end_src

***** DONE Make sure Org is installed (straight.el)
[[https://github.com/org-roam/org-roam/issues/2361][Freezing Org@9.5.5]] fixes the issue with org-roam resulting in 'Wrong type argument: integer-or-marker-p, nil'

#+begin_src elisp :tangle ~/.emacs
(unless (file-directory-p "~/.emacs.d/straight/versions") (make-directory (concat user-emacs-directory "straight/versions")))
#+end_src

#+begin_src elisp :tangle ~/.emacs.d/straight/versions/default.el
  ;;  (("org" . "8ef6205a560cd3a92f8c5f8fe34953b80121c2cb")) ; org@9.5.5
  (("org" . "5890aca3d29e593640b728308096a052998355b1")) ; org@9.6.7
     :gamma
#+end_src

#+begin_src elisp :tangle ~/.emacs
  (use-package org)
#+end_src

**** DONE Tangle emacs.org

#+begin_src elisp :tangle ~/.emacs
  (require 'ob-tangle)
  
  ;; Specify the input file and the output directory
  (defvar config-org-file "~/org/notes/emacs.org")
  (defvar config-el-file "~/.emacs.d/config.el")
  (defvar org-use-property-inheritance t)

  ;; Tangle emacs.org into config.el and load config.el
  (org-babel-tangle-file config-org-file)
  (load-file config-el-file)
#+end_src

**** DONE Garbage collector - decrease threshold to 5 MB
#+begin_src elisp :tangle ~/.emacs
  (add-hook 'after-init-hook (lambda () (setq gc-cons-threshold (* 5 1024 1024))))
#+end_src

**** DONE End matter
#+begin_src elisp :tangle ~/.emacs
  (provide '.emacs)
  ;;; .emacs ends here
#+end_src

* TODO [8/11] config.el and custom.el

This Emacs configuration file is a fork of [[https://sriramkswamy.github.io/dotemacs/][Sri Ramkswamy's]] and [[https://pages.sachachua.com/.emacs.d/Sacha.html][Sacha Chusa's]] settings. I am sure there is much more to learn from them as I go. Worth revisiting.

** DONE Front matter
#+begin_src elisp
  ;;; Package --- Summary
  ;;; Commentary:
  ;;; Code:

  ;; -*- lexical-binding: t; -*-
#+end_src

#+begin_src elisp :tangle ~/.emacs.d/custom.el
  ;;; Package --- Summary
  ;;; Commentary:
  ;;; Code:

  ;; -*- lexical-binding: t; -*-
#+end_src

** DONE [9/9] Startup and general configurations
   :LOGBOOK:
   - State "DONE"       from "DONE"       [2024-07-20 Sat 11:55]
   - State "DONE"       from "TODO"       [2024-07-19 Fri 15:10]
   - State "DONE"       from "TODO"       [2024-07-10 Wed 10:45]
   :END:

*** DONE Run Emacs as a server

#+begin_src elisp :tangle ~/.emacs.d/early-init.el
  (require 'server)
  (unless (server-running-p) (server-start))
  (defvar server-max-buffers 100)
#+end_src

*** DONE Custom file

#+begin_src elisp
  (setq custom-file (expand-file-name "custom.el" user-emacs-directory))
  (when (file-exists-p custom-file) (load custom-file))
#+end_src

*** DONE [[https://github.com/jwiegley/use-package][use-package]]
:PROPERTIES:
:CLOSED:   [2023-01-22 Sun 09:36]
:END:
:LOGBOOK:
- State "DONE"       from "CNCL"       [2024-07-16 Tue 18:02]
:END:

"A use-package declaration for simplifying your .emacs"

#+begin_src elisp
  (require 'use-package)
;;  (require 'bind-key)
    ;;  (require 'use-package-ensure)
    ;;  (setq use-package-always-ensure t) ; Ensure use-package installs all packages by default. Use :ensure nil to override.
    ;;  (package-install-selected-packages)
#+end_src

*** CNCL [[https://github.com/quelpa/quelpa][Quelpa]]

#+begin_src elisp :tangle no
  (unless (package-installed-p 'quelpa)
    (with-temp-buffer
      (url-insert-file-contents "https://raw.githubusercontent.com/quelpa/quelpa/master/quelpa.el")
      (eval-buffer)
      (quelpa-self-upgrade)))
#+end_src

*** DONE System information
:LOGBOOK:
- State "DONE"       from "TODO"       [2023-08-28 Mon 18:46]
- State "DONE"       from "DONE"       [2023-08-28 Mon 18:43]
- State "DONE"       from "NEXT"       [2023-08-03 Thu 13:03]
:END:

I took this from [[https://pages.sachachua.com/.emacs.d/Sacha.html][Sacha's settings]]. This allows for tweaking configuations according to platform. I intend to use more of this more as I develop Emacs configs across platforms.

#+begin_src elisp  :tangle ~/.emacs.d/custom.el
  (defvar my-laptop-p (equal (system-name) "lilitop"))
  (defvar my-server-p (and (equal (system-name) "localhost") (equal user-login-name "root")))
  (defvar my-phone-p (not (null (getenv "ANDROID_ROOT")))
    "If non-nil, GNU Emacs is running on Termux.")
  (when my-phone-p (defvar gnutls-algorithm-priority "NORMAL:-VERS-TLS1.3"))
  (global-auto-revert-mode)  ; simplifies syncing
#+end_src

*** DONE Persistent history

#+begin_src elisp
  (savehist-mode)
#+end_src

*** DONE Personal information

#+begin_src elisp :tangle ~/.emacs.d/custom.el
  (setq user-full-name "Amr Gharbeia")
  (defvar email-address "amr@gharbeia.net")
  (defvar calendar-latitude 39.0)
  (defvar calendar-longitude -77.1)
  (defvar calendar-location-name "Washington, DC")
  (defvar calendar-time-zone -300)
  (defvar calendar-standard-time-zone-name "EST")
  (defvar calendar-daylight-time-zone-name "EDT")
#+end_src

** TODO [2/3] Advanced Features
*** TODO [0/2] Text
**** TODO [0/1] Case
***** TODO Convert DOuble capitals to single capitals
:LOGBOOK:
- State "DONE"       from "TODO"       [2024-06-27 Thu 13:02]
- State "DONE"       from "NEXT"       [2023-08-09 Wed 13:51]
:END:

#+begin_src elisp :tangle no
  (defun my/dcaps-to-scaps ()
    "Convert word in DOuble CApitals to Single Capitals."
    (interactive)
    (and (= ?w (char-syntax (char-before)))
         (save-excursion
           (and (if (called-interactively-p)
                    (skip-syntax-backward "w")
                  (= -3 (skip-syntax-backward "w"))
                  )
                (let (case-fold-search)
                  (looking-at "\\b[[:upper:]]\\{2\\}[[:lower:]]")
                  )
              (capitalize-word 1)
              )
           )
         )
    )
#+end_src

Then, let’s define a minor mode for it to be activated.

#+begin_src elisp :tangle no
  (define-minor-mode my-dubcaps-mode
    "Toggle 'my-dubcaps-mode' and convert words in DOuble CApitals to Single Capitals as you type."
    :init-value nil
    :lighter (" DC")
    (if my-dubcaps-mode
        (add-hook 'post-self-insert-hook #'my/dcaps-to-scaps nil 'local)
      (remove-hook 'post-self-insert-hook #'my/dcaps-to-scaps 'local)))
#+end_src

 Finally, let’s add a hook so that it is on for all the text files Emacs opens.
 
#+begin_src elisp :tangle no
  (add-hook 'text-mode-hook #'my-dubcaps-mode)  
#+end_src

Also, since we add a minor mode string (it might be useful sometimes), currently I prefer to diminish it.

#+begin_src elisp :tangle no
  (defun my/diminish-dubcaps ()
    (interactive)
    (diminish 'my-dubcaps-mode ""))
  (add-hook 'my-dubcaps-mode-hook 'my/diminish-dubcaps)
#+end_src

**** Text Mode
**** Outline Mode
**** TODO [4/10] Org Mode
   :LOGBOOK:
   - State "DONE"       from "TODO"       [2024-02-28 Wed 16:49]
   :END:
   
***** DONE Basic setup

#+begin_src elisp
  (use-package org
    :config
    (defvar org-outline-path-complete-in-steps nil)
    :bind (("C-c l" . org-store-link)
  	 ("C-c a" . org-agenda)
  	 ("C-c c" . org-capture)
  	 :map org-mode-map)
    )
#+end_src

#+begin_src elisp :tangle ~/.emacs.d/custom.el
  (defvar org-directory (concat (getenv "HOME") "/org/"))
#+end_src

***** DONE [6/6] Looks
    :LOGBOOK:
    - State "DONE"       from "TODO"       [2024-07-19 Fri 15:58]
    - State "DONE"       from "TODO"       [2024-07-16 Tue 21:51]
    :END:

****** DONE Basic 
#+begin_src elisp
  (defvar org-pretty-entities t) ; Improve org mode looks
  (defvar org-hide-emphasis-markers t) ; Hide emphasis markup
  (defvar org-num-mode nil)
  (defvar org-startup-folded 'shw2levels)
#+end_src

****** DONE Indentation of headers
     :LOGBOOK:
     - State "DONE"       from "TODO"       [2024-07-16 Tue 21:27]
     - State "DONE"       from              [2023-08-28 Mon 18:17]
     :END:

#+begin_src elisp
  (defvar org-startup-indented t) ; Indent org heirarchy
  (defvar org-adapt-indentation t)
  (defvar org-hide-leading-stars t) ; Minimal Outline
  (defvar org-odd-levels-only nil)
#+end_src

****** DONE Indentation of lists
:LOGBOOK:
- State "DONE"       from              [2024-02-11 Sun 13:15]
:END:

#+begin_src elisp
  (setq org-list-demote-modify-bullet t)
#+end_src

****** DONE [[https://github.com/minad/org-modern][Org-modern]]
:LOGBOOK:
- State "DONE"       from "TODO"       [2024-07-16 Tue 21:27]
- State "DONE"       from "TODO"       [2024-06-27 Thu 13:06]
:END:

#+begin_src elisp
  (use-package org-modern
    :config
    
    ;; Choose some fonts
    (set-face-attribute 'default nil :family "sans-serif")
    (set-face-attribute 'variable-pitch nil :family "sans-serif")
    (set-face-attribute 'org-modern-symbol nil :family "Iosevka")

    ;; Edit settings
    (defvar org-auto-align-tags nil)
    (defvar org-tags-column 0)
    (defvar org-catch-invisible-edits 'show-and-error)
    (defvar org-special-ctrl-a/e t)
    (defvar org-insert-heading-respect-content t)

     ;; Org styling, hide markup etc.
     (defvar org-hide-emphasis-markers t)
     (defvar org-pretty-entities t)

     ;; Agenda styling
     (defvar org-agenda-tags-column 0)
     (defvar org-agenda-block-separator ?─)
     (defvar org-agenda-time-grid
       '((daily today require-timed)
         (800 1000 1200 1400 1600 1800 2000)
         " ┄┄┄┄┄ " "┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄"))
     (defvar org-agenda-current-time-string
       "◀── now ─────────────────────────────────────────────────")

    ;; Ellipsis styling
     (defvar org-ellipsis "…")
     (set-face-attribute 'org-ellipsis nil :inherit 'default :box nil)
    
     (global-org-modern-mode)
    )
  #+end_src

****** DONE Highlight Sourcecode Syntax

#+begin_src elisp
  (setq org-src-fontify-natively t)
  (setq org-src-tab-acts-natively t)
#+end_src

****** DONE Images
:LOGBOOK:
- State "DONE"       from "TODO"       [2024-07-19 Fri 15:34]
:END:

#+begin_src elisp
  (setq org-startup-with-inline-images t)
  (setq org-image-actual-width '(300))
#+end_src

***** TODO [3/5] Agenda
****** DONE Basic agenda settings
:LOGBOOK:
- State "DONE"       from "TODO"       [2024-07-19 Fri 15:52]
:END:

#+begin_src elisp
   (setq org-deadline-warning-days 7)
   (setq org-agenda-skip-additional-timestamps-same-entry t)
   (setq org-agenda-span 'fortnight)
   (setq org-agenda-tags-column 'auto)
   (setq org-agenda-skip-scheduled-if-deadline-is-shown t)
#+end_src

****** DONE Agenda files

#+begin_src elisp
  (setq org-agenda-files (list
  			(concat org-directory "/inbox.org")
  			(concat org-directory "/org-gtd-tasks.org")
  			)
        )
#+end_src

****** TODO [[https://github.com/alphapapa/org-super-agenda][Better agenda views]]

#+begin_src elisp :tangle no
  (use-package org-super-agenda)
#+end_src

****** DONE [6/6] To-do
:LOGBOOK:
- State "DONE"       from "TODO"       [2024-07-19 Fri 15:53]
:END:

******* DONE Basic todo
:LOGBOOK:
- State "DONE"       from "TODO"       [2024-07-19 Fri 15:53]
:END:

#+begin_src elisp
  (setq org-todo-keywords
          '(
            (sequence "TODO(t)" "NEXT(n)" "|" "DONE(d!)")
            (sequence "WAIT(w@/!)" "|" "CNCL(c@)")
            )
          )

  (setq org-todo-keyword-faces
          '(
            ("TODO" :foreground "red" :weight bold)
            ("NEXT" :foreground "red" :weight bold)
            ("WAIT" :foreground "yellow" :weight bold)
            ("DONE" :foreground "green" :weight bold)
            ("CNCL" :foreground "blue" :weight bold)
            )
          )

  (setq org-enforce-todo-dependencies t)
  (setq org-tags-exclude-from-inheritance '("crypt" "!private"))
#+end_src

******* DONE Switch entry to 'DONE' when all subentries are done

#+begin_src elisp
  (defun org-summary-todo (n-done n-not-done)
    "Switch entry to 'DONE' when all subentries are done, to 'TODO' otherwise.
  Uses N-DONE and N-NOT-DONE"
    (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

******* DONE [[https://github.com/Trevoke/org-gtd.el][Getting Things Done (GTD)]]

I am now relying on [[https://github.com/Trevoke/org-gtd.el][org-gtd]] to create a GTD workflow:
1. everything comes into ~/org/inbox.org
2. Items are clarified with textual context, then with including:
   - a horizon
   - tags

   Items are then goes into one of the following buckets:

   - a single action
   - a project
   - an action within an existing project
   - a sometime/maybe
   - a habit
   - a knowledge/reference item
   - discarded as trash

3. The above categories are all now headers in ~/org-gtd-tasks.org, but should each have their own file in the future.
4. All actions are states

   - TODO (instead of NEXT. Will decide if I will use next per the orthdoxy)
   - WAIT
   - DONE
   - CNCL

   I also used to have MAYBE and STARTED tags. Maybe to avoid having a different pool for it (GTD is old, relies on paper and is therefore sequential. Computers solved this problem). STARTED was the tag for the things I am doing, because my NEXT (TODO) list is huge at the moment, mainly because of decades of backlog.
5. Reference is ~/org/library.org. I am beginning to think I might split this further as it grows. My main ~/library is massive, obviously.
6. Calendar is still half connected to org-mode and GTD. Need to find a way to connect across devices. [[https://github.com/dengste/org-caldav][org-caldav]] looks promising.

#+begin_src elisp
  (use-package org-gtd
    :defer t
    :init (setq org-gtd-update-ack "3.0.0")
    :after org
    :config
    ;; Keeping these two settings on instead of enabling (org-gtd-mode) until this issue is resolved https://github.com/Trevoke/org-gtd.el/issues/198
    (setq org-edna-use-inheritance t)
    (org-edna-mode)
    ;;    (org-gtd-mode)
    :bind (
  	 ("C-c d c" . org-gtd-capture)
  	 ("C-c d e" . org-gtd-engage)
  	 ("C-c d p" . org-gtd-process-inbox)
  	 :map org-gtd-clarify-map
  	 ("C-c c" . org-gtd-organize)
  	 )
    )
#+end_src

#+begin_src elisp :tangle ~/.emacs.d/custom.el
  (defvar org-gtd-directory org-directory)
  (defvar org-gtd-organize-hooks '(org-gtd-set-area-of-focus org-set-tags-command))
  (defvar org-gtd-organize-hooks '(org-gtd-set-area-of-focus))
  (defvar org-gtd-areas-of-focus '(
  				 "Atoms"
  				 "Bits"
  				 "Cells"
  				 "Flags"
  				 "Business"
  				 "Wealth"
  				 "Learning"
  				 "Skills"
  				 "Privacy"
  				 "Archive"
  				 "Library"
  				 "Writing"
  				 "Health"
  				 "Home"
  				 "Family"
  				 "Social"
  				 "Egypt"
  				 )
    )
  (defvar org-gtd-clarify-show-horizons 'right)
#+end_src

******* DONE Logging
CLOSED: [2023-07-31 Mon 16:49]

#+begin_src elisp
  (setq org-log-into-drawer "LOGBOOK")
#+end_src

******* DONE Clocking work in drawer
:LOGBOOK:
- State "DONE"       from "NEXT"       [2023-08-03 Thu 13:16]
:END:

#+begin_src elisp
  (setq org-clock-into-drawer t)
#+end_src

******* DONE Habits
:LOGBOOK:
- State "DONE"       from "TODO"       [2024-07-16 Tue 21:36]
- State "DONE"       from "TODO"       [2023-07-31 Mon 14:33]
:END:

#+begin_src elisp
  (setq org-habit-graph-column 80)
  (setq org-habit-show-habits-only-for-today nil)
#+end_src

****** TODO [1/3] Reifle
********* DONE org-refile targets
:LOGBOOK:
- State "DONE"       from "TODO"       [2024-07-16 Tue 21:38]
- State "DONE"       from "TODO"       [2023-07-07 Fri 16:51]
:END:

Allow refiling to agenda files, nine headers deep, either in current buffer or in agenda files.

#+begin_src elisp
  (setq org-refile-targets '((nil :maxlevel . 9)
                             (org-agenda-files :maxlevel . 9)
                             )
        )
#+end_src

********* TODO Set type of refile targets completion
:LOGBOOK:
- State "DONE"       from "TODO"       [2023-07-07 Fri 16:50]
:END:

  This setting is related to the completion of refile targets. If set to `t`, you build the path in steps by selecting one note at a time. This might be useful with deep hierarchies, but can be slow. When set to `nil`, you can enter the path directly, and Org-Mode uses a Helm-like interface to auto-complete the path. This can be faster, but possibly more difficult with deep hierarchies.
   
#+begin_src elisp :tangle no
  (setq org-outline-path-complete-in-steps nil)
#+end_src

********* TODO Allow refiling to new parents created on the go after confirmation
:LOGBOOK:
- State "DONE"       from "TODO"       [2023-07-07 Fri 16:50]
:END:
  
#+begin_src elisp :tangle no
  (setq org-refile-allow-creating-parent-nodes 'confirm)
#+end_src

***** TODO [1/2] Capture
:LOGBOOK:
- State "DONE"       from "DONE"       [2024-07-19 Fri 15:50]
- State "DONE"       from "DONE"       [2023-08-17 Thu 14:06]
- State "DONE"       from "DONE"       [2023-08-11 Fri 14:16]
- State "DONE"       from "TODO"       [2023-07-05 Wed 16:51]
:END:

#+begin_src elisp :tangle ~/.emacs.d/custom.el
  (defvar org-default-notes-file (concat org-directory "/inbox.org"))
#+end_src

****** DONE [4/4] Org-protocol
:LOGBOOK:
- State "DONE"       from "DONE"       [2024-07-19 Fri 15:49]
- State "DONE"       from "TODO"       [2023-07-05 Wed 13:21]
:END:

******* DONE Linux  configuration
For GNU/Linux setup, put this in ~/.local/share/applications/org-protocol.desktop
or in /usr/share/applications to set up system-wide.

#+begin_src bash :tangle no
[Desktop Entry]
Name=org-protocol
Comment=Intercept calls from emacsclient to trigger custom actions
Categories=Other;
Keywords=org-protocol;
Icon=emacs
Type=Application
Exec=emacsclient -- %u
Terminal=false
StartupWMClass=Emacs
MimeType=x-scheme-handler/org-protocol;
#+end_src

then update the cache database of MIME types handled by desktop files:

#+begin_src bash :tangle no
update-desktop-database ~/.local/share/applications/
#+end_src

******* DONE Basic configuration

#+begin_src elisp
  (require 'org-protocol)
  (setq org-protocol-default-buffer-for-file-links "*scratch*") ; fixes 'no buffers remain to edit error for org-protocol capturer
  #+end_src

******* DONE Org-protocol templates

And finally, here are the capture templates for org-protocol captures.

#+begin_src elisp :tangle ~/.emacs.d/custom.el
  (defvar org-capture-templates '(
                                ("p" "Protocol"
                                 entry
                                 (file "inbox.org")
                                 "* %^{Title}\nSource: %u, %c\n #+BEGIN_QUOTE\n%i\n#+END_QUOTE\n\n\n%?"
                                 )
                                ("L" "Protocol Link"
                                 entry
                                 (file "inbox.org")
                                 "* %? [[%:link][%:description]]\n:PROPERTIES:\n:TITLE: %:description\n:URI: %:link\n:CREATED: %U\n:END:"
                                 :prepend nil
                                 :empty-lines 1
                                 :created t
                                 :kill-buffer t
                                 )
                                )
        )
#+end_src

#+begin_src elisp
  (setq org-protocol-default-template-key "L")
#+end_src

******* DONE Convert Orgzly captures to org-protocol captures standard
:LOGBOOK:
- State "DONE"       from "TODO"       [2023-07-10 Mon 11:52]
:END:

This will create clickable titles, create "TITLE", " URL", and "CREATED" properties

#+begin_src elisp
  (defun my/org-convert-orgzly-to-org-protocol ()
    "Reformat Orgzly bookmark at point to org-protocol bookmark."
    (interactive)
    (when (org-at-heading-p)
      (let ((headline (nth 4 (org-heading-components))))
        ;; Find and store the link. Delete the link line.
        (search-forward-regexp "^https?://\\S-*" nil t)
        (let ((link (match-string 0)))
          (beginning-of-line)
          (kill-line)
          ;; Delete any trailing blank spaces
          (org-back-to-heading)
          (end-of-line)
          (when (not (org-on-heading-p))
            (delete-char 1)
            )
          ;; Set new headline
          (goto-char (org-entry-beginning-position))
          (org-edit-headline (format "[[%s][%s]]" link headline))
          ;; Set new properties
          (org-set-property "TITLE" headline)
          (org-set-property "URI" link)
          (message "Reformatted Orgzly bookmark at point to org-protocol bookmark")
          )
        )
      )
    )
#+end_src

****** TODO org-roam-capture templates
:LOGBOOK:
- State "DONE"       from "TODO"       [2023-08-19 Sat 18:17]
:END:

#+begin_src elisp
  (setq org-roam-capture-templates
        '(
          ("L" "link" plain
           (function org-roam--capture-get-point)
           "%?"
           :file-name "web/%<%Y-%m-%dT%H%M%S>.org"
           :head "#+TITLE: ${title}\n#+CREATED: %<%Y-%m-%dT%H%M%S>"
           :immediate-finish t
           :unnarrowed t
           )

          ("h" "hugo post" plain
           "%?"
           :target (file+head "posts/${slug}.org"
                              "#+TITLE: ${title}\n#+DATE: %U\n#+HUGO_BASE_DIR: ~/gharbeia.net\n#+HUGO_SECTION: ./posts\n#+HUGO_AUTO_SET_LASTMOD: t\n#+HUGO_TAGS: article\n#+HUGO_DRAFT: true\n")
           :immediate-finish t
           :unnarrowed t
           )

          ("p" "person" plain
           "%?"
           :if-new (file+head "people/${slug}.org"
                             "#+TITLE: ${title}")
          :immediate-finish t
          :unnarrowed t
          )
         )
       )
#+end_src

#+begin_src elisp
  (setq org-roam-dailies-capture-templates
        '(
          ("d" "daily" plain
           ""
          :target ("file+heaed %<%Y-%m-%d>.org"  "#+title: %<%Y-%m-%d>\n\n")
          :immediate-finish t
          )
         )
       )
#+end_src

***** TODO [3/5] Org-roam
****** DONE Basic org-roam setup
:LOGBOOK:
- State "DONE"       from "TODO"       [2024-07-16 Tue 21:30]
- State "DONE"       from "TODO"       [2023-07-05 Wed 17:11]
:END:

#+begin_src elisp
  (use-package org-roam
    :init (setq org-roam-v2-ack t) ;; Acknowledge V2 upgrade
    :after org
    :config
    (org-roam-db-autosync-enable)
    (require 'org-roam-dailies)
    (setq org-roam-mode-sections
  	(list #'org-roam-backlinks-section
                #'org-roam-reflinks-section
                #'org-roam-unlinked-references-section
                )
  	)
    (add-to-list 'display-buffer-alist
                 '("\\*org-roam\\*"
                   (display-buffer-in-side-window)
                   (side . right)
                   (slot . 0)
                   (window-width . 0.33)
                   (window-parameters . ((no-other-window . t)
                                         (no-delete-other-windows . t)))))
    :bind  (
  	  ("C-c n f" . org-roam-node-find)
  	  ("C-c n g" . org-roam-graph)
  	  ("C-c n r" . org-roam-node-random)
  	  ("C-c n h" . org-roam-node-convert-headline)
  	  ("C-c n i" . org-roam-node-insert)
  	  ("C-c n o" . org-id-get-create)
  	  ("C-c n t" . org-roam-tag-add)
  	  ("C-c n a" . org-roam-alias-add)
  	  ("C-c n l" . org-roam-buffer-display-dedicated)
  	  )
    )
#+end_src

#+begin_src elisp :tangle ~/.emacs.d/custom.el
  (setq org-roam-directory org-directory)
  (setq org-roam-dailies-directory (concat org-roam-directory "daily"))
#+end_src

****** DONE Include subdirectories in org-roam
:PROPERTIES:
    :CREATED:  [2023-07-06 Thu 03:18]
    :END:
:LOGBOOK:
- State "DONE"       from "TODO"       [2024-07-19 Fri 16:45]
- State "DONE"       from "TODO"       [2023-07-06 Thu 12:54]
:END:

#+begin_src elisp
  (setq org-roam-file-exclude-regexp "^[.][.]?/")
#+end_src

****** DONE Configure what display in org-roam-buffer
:LOGBOOK:
- State "DONE"       from "TODO"       [2024-07-19 Fri 16:47]
:END:

Note that computing unlinked references may be slow, and has not been added in by default.

    #+begin_src elisp
      (setq org-roam-mode-sections
            (list #'org-roam-backlinks-section
                  #'org-roam-reflinks-section
                  #'org-roam-unlinked-references-section 
                  )
            )
#+end_src

****** TODO [[https://emacs.stackexchange.com/questions/61290/how-to-see-files-of-a-particular-tag-in-org-roam][Filter org-roam nodes find by tag]]
:PROPERTIES:
    :TITLE:    org mode - How to see files of a particular tag in org-roam? - Emacs Stack Exchange
    :URI:      https://emacs.stackexchange.com/questions/61290/how-to-see-files-of-a-particular-tag-in-org-roam
    :CREATED:  [2023-08-19 Sat 12:47]
    :END:
:LOGBOOK:
- State "DONE"       from "TODO"       [2023-08-19 Sat 18:13]
:END:

#+begin_src elisp :tangle no
  (defun my/org-roam-node-has-tag (node tag)
    "Filter function to check if the given NODE has the specified TAG."
    (member tag (org-roam-node-tags node))
    )

  (defun my/org-roam-node-find-by-tag ()
    "Find and open an Org-roam node based on a specified tag."
    (interactive)
    (let ((tag (read-string "Enter tag: ")))
      (org-roam-node-find nil nil (lambda (node) (my/org-roam-node-has-tag node tag))))
    )
#+end_src

****** TODO [0/3]  Move org header to org-roam-daily
******* TODO OpenAI
#+begin_src elisp :tangle no
  (defun my/org-move-entry-to-daily-notes ()
    "Move the current org-mode headline to the daily notes file based on its :CREATED: property."
    (interactive)
    (let*
        (
         (created-prop (org-entry-get nil "CREATED"))
         (created-date (when created-prop
                         (org-parse-time-string created-prop)))
         (year (nth 5 created-date)) ; Extract year (6th element)
         (month (nth 4 created-date)) ; Extract month (5th element)
         (day (nth 3 created-date)) ; Extract day (4th element)
         (target-date (format "%04d-%02d-%02d" year month day)) ; Format date string
         (target-file (org-roam-dailies-goto target-date)) 
         )
      (when target-file
        (org-cut-subtree)
        (find-file target-file)
        (goto-char (point-max))
        (unless (bolp) (newline))
        (org-paste-subtree)
        )
      )
  )
#+end_src

#+begin_src elisp :tangle no
    (defun my/org-move-entry-to-daily-notes ()
      "Move the current org-mode headline to the daily notes file based on its :CREATED: property."
      (interactive)
      (let*
        (
         (created-prop (org-entry-get nil "CREATED"))
         (created-date (when created-prop
                         (org-parse-time-string created-prop)))
         (year (nth 5 created-date)) ; Extract year (6th element)
         (month (nth 4 created-date)) ; Extract month (5th element)
         (day (nth 3 created-date)) ; Extract day (4th element)
         (target-date (format "%04d-%02d-%02d" year month day)) ; Format date string
         ;(target-date "2024-01-01")
         (target-file (concat org-roam-dailies-directory "/" target-date ".org"))
         (find-file target-file)
         )
      )
      (when target-file
        (org-cut-subtree)
        (find-file target-file)
        (org-id-get-create)
  ;; #+title: target-date
        (goto-char (point-max))
        (unless (bolp) (newline))
        (org-paste-subtree)
        )
      )
#+end_src

******* TODO [[https://git.ikl.sh/132ikl/dotfiles/src/branch/main/.doom.d/lisp/refile.el][Modified rose Refile to org-roam-dailies]]

Arrived to from [[https://www.reddit.com/r/OrgRoam/comments/ruc59q/tips_for_refiling_into_org_roam_dailies/][this conversation]]

Here's a breakdown of the functions and their roles:

0. org-roam-dailies--capture

#+begin_src elisp :tangle no
  (defun org-roam-dailies--capture (time &optional goto keys)
  "Capture an entry in a daily-note for TIME, creating it if necessary.
When GOTO is non-nil, go the note without creating an entry.

ELisp programs can set KEYS to a string associated with a template.
In this case, interactive selection will be bypassed."
  (let ((org-roam-directory (expand-file-name org-roam-dailies-directory org-roam-directory))
        (org-roam-dailies-directory "./"))
    (org-roam-capture- :goto (when goto '(4))
                       :keys keys
                       :node (org-roam-node-create)
                       :templates org-roam-dailies-capture-templates
                       :props (list :override-default-time time)))
  (when goto (run-hooks 'org-roam-dailies-find-file-hook)))
#+end_src


1. `my/refile`: This function refiles a single headline by finding the file, reverting the buffer, and replacing fuzzy links with roam: links.

#+begin_src elisp :tangle no
      ;;; lisp/refile.el -*- lexical-binding: t; -*-
    (defun my/refile ()
        "Refiles a headline (and its subtree) with a CREATED property to its corresponding daily."
      (interactive)
      (revert-buffer t t)
      ;; replace fuzzy links with roam: links (exclude non-fuzzy links, ie. links with `:')
      (while (re-search-forward "\\[\\[\\([^:]+?\\)\\]\\]" nil t)
        (replace-match "[[roam:\\1]]" nil nil))
  ;    (org-roam-link-replace-all) ;; TODO create blank page if non-existent
      ;; remove blank lines because i think they are ugly
      (while (re-search-forward "\n+" nil t)
        (replace-match "\n" nil nil))
      (let ((entries (org-map-entries #'my/refile--inbox-headline nil 'file)))
        (message (format "Refiled %d headline(s)" (seq-count #'identity entries)))
        )
      )
#+end_src   

2. `my/refile--inbox-headline`: This function refiles a headline at the current point by deleting the CREATED property and capturing the headline using org-capture.

#+begin_src elisp :tangle no
  (defun my/refile--inbox-headline ()
    "Refile headline at POINT."
    (setq org-map-continue-from (point))
    (if-let (capture-template (my/refile--get-template))
        (my/refile--capture capture-template)
      (my/refile--to-node)))
#+end_src

3. `my/refile--capture`: This function runs org-capture on an inbox heading and inserts the result into the buffer.

#+begin_src elisp :tangle no
  (defun my/refile--capture (capture-template)
    "Run 'org-capture' on inbox heading using CAPTURE-TEMPLATE."
    ;; (org-entry-delete nil "CREATED")
    (let ((keys (car capture-template))
          (heading (cdr capture-template))
          (entry (org-no-properties (org-get-entry))))
      (org-capture nil keys)
      (insert heading "\n" entry))
    (org-capture-finalize)
    (org-cut-subtree)
    )
#+end_src

4. `my/refile--get-template`: This function parses the capture template prefix from the heading and returns a cons cell containing the keys and heading.

#+begin_src elisp :tangle no
  (defun my/refile--get-template ()
    "Parse capture template prefix from heading."
    (when-let* ((raw-heading (org-no-properties (org-get-heading)))
                (match (string-match "@\\(\\w+\\) \\(.+\\)$" raw-heading))
                (keys (match-string-no-properties 1 raw-heading))
                (heading (match-string-no-properties 2 raw-heading)))
      (cons keys heading))
    )
#+end_src   
   
5. `my/refile--to-node`: This function refiles a headline to an Org-roam node.

#+begin_src elisp :tangle no
  (defun my/refile--to-node ()
    "Refiles non-capture headings to org-roam node."
    (if-let ((to (+org/entry-get-delete "TO")))
        (my/refile--org-roam-node (org-roam-node-from-title-or-alias to))
      (my/refile--to-daily)))
#+end_src

6. `my/refile--to-daily`: This function refiles a headline to a daily node based on its CREATED property.

#+begin_src elisp :tangle no
  (defun my/refile--to-daily ()
    "Refile headline at POINT to the associated daily node based on its `CREATED' property."
    (when-let* ((created (org-entry-get nil "CREATED"))
                (time (org-time-string-to-time created))
                (daily-node (my/refile--get-daily-node time)))
      (org-entry-delete nil "CREATED")
      (my/refile--org-roam-node daily-node)))
#+end_src
   
7. `my/refile--get-daily-node`: This function returns the Org-roam node for a given time.

#+begin_src elisp :tangle no
  (defun my/refile--get-daily-node (time)
    "Return org-roam node for TIME."
    (save-window-excursion
      (org-roam-dailies--capture time t)
      (org-roam-node-at-point)))
#+end_src

8. `my/refile--org-roam-node`: This function refiles a node to an Org-roam node.

   The `my/refile--org-roam-node` function is quite long and complex, but it seems to be responsible for refiling a node to an Org-roam node. It takes several arguments, including the node to refile, and uses several org-roam functions to perform the refiling.

#+begin_src elisp :tangle no
  (defun my/refile--org-roam-node (node)
    "Refile NODE at point to an Org-roam node.
  If region is active, then use it instead of the node at point.
  Implementation of `org-roam-refile' from org-roam PR #2388."
    (interactive
     (list (org-roam-node-read nil nil nil 'require-match)))
    (let* ((regionp (org-region-active-p))
           (region-start (and regionp (region-beginning)))
           (region-end (and regionp (region-end)))
           (file (org-roam-node-file node))
           (nbuf (or (find-buffer-visiting file)
                     (find-file-noselect file)))
           level reversed)
      (if (equal (org-roam-node-at-point) node)
          (user-error "Target is the same as current node")
        (if regionp
            (progn
              (org-kill-new (buffer-substring region-start region-end))
              (org-save-markers-in-region region-start region-end))
          (progn
            (if (org-before-first-heading-p)
                (org-roam-demote-entire-buffer))
            (org-copy-subtree 1 nil t)))
        (with-current-buffer nbuf
          (org-with-wide-buffer
           (goto-char (org-roam-node-point node))
           (setq level (org-get-valid-level (funcall outline-level) 1)
                 reversed (org-notes-order-reversed-p))
           (goto-char
            (if reversed
                (or (outline-next-heading) (point-max))
              (or (save-excursion (org-get-next-sibling))
                  (org-end-of-subtree t t)
                  (point-max))))
           (unless (bolp) (newline))
           (org-paste-subtree level nil nil t)
           (and org-auto-align-tags
                (let ((org-loop-over-headlines-in-active-region nil))
                  (org-align-tags)))
           (when (fboundp 'deactivate-mark) (deactivate-mark))))
        (if regionp
            (delete-region (point) (+ (point) (- region-end region-start)))
          (org-preserve-local-variables
           (delete-region
            (and (org-back-to-heading t) (point))
            (min (1+ (buffer-size)) (org-end-of-subtree t t) (point)))))
        ;; If the buffer end-up empty after the refile, kill it and delete its
        ;; associated file.
        (when (eq (buffer-size) 0)
          (if (buffer-file-name)
              (delete-file (buffer-file-name)))
          (set-buffer-modified-p nil)
          ;; If this was done during capture, abort the capture process.
          (when (and org-capture-mode
                     (buffer-base-buffer (current-buffer)))
            (org-capture-kill))
          (kill-buffer (current-buffer))))))
#+end_src   

#+begin_src elisp :tangle no
  (defun +org/entry-get-delete (entry)
  (prog1 (org-entry-get nil entry) (org-entry-delete nil entry)))
#+end_src

******* TODO [[https://systemcrafters.net/build-a-second-brain-in-emacs/5-org-roam-hacks/#automatically-copy-or-move-completed-tasks-to-dailies][Automatically copy (or move) completed tasks to dailies]]
#+begin_src elisp :tangle no
  (defun my/org-roam-copy-todo-to-today ()
    (interactive)
    (let ((org-refile-keep t) ;; Set this to nil to delete the original!
          (org-roam-dailies-capture-templates
            '(("t" "tasks" entry "%?"
               :if-new (file+head+olp "%<%Y-%m-%d>.org" "#+title: %<%Y-%m-%d>\n" ("Tasks")))))
          (org-after-refile-insert-hook #'save-buffer)
          today-file
          pos)
      (save-window-excursion
        (org-roam-dailies--capture (current-time) t)
        (setq today-file (buffer-file-name))
        (setq pos (point)))

      ;; Only refile if the target file is different than the current file
      (unless (equal (file-truename today-file)
                     (file-truename (buffer-file-name)))
        (org-refile nil nil (list "Tasks" today-file nil pos)))))

  (add-to-list 'org-after-todo-state-change-hook
               (lambda ()
                 (when (equal org-state "DONE")
                   (my/org-roam-copy-todo-to-today))))
#+end_src

***** TODO Exporting

From [[https://sriramkswamy.github.io/dotemacs/#orgheadline29][Sriramkswamy]]:

#+BEGIN_QUOTE
Org has a powerful exporting feature. Let’s select the various formats to export and also mention how exactly we need it to export to LaTeX with syntax highlighting. I have also taken a good looking CSS configuration from [[http://gongzhitaao.org/orgcss/][Zhitao Gong]] and I use it for exporting by putting it [[https://sriramkswamy.github.io/dotemacs/org.css][in the same folder as my org file]] and adding #+HTML_HEAD: <link rel="stylesheet" type="text/css" href="org.css"/>  to the top of my org file.
#+END_QUOTE

#+begin_src elisp :tangle no
  (setq org-export-with-smart-quotes t)
  (setq org-export-backends '(beamer html latex md))
#+end_src

***** DONE org-attach

#+begin_src elisp :tangle ~/.emacs.d/custom.el
  (defvar org-attach-id-dir (concat org-directory "/library/documents"))
#+end_src

***** DONE Enable shell scripting support in org-babel

#+begin_src elisp
  (defvar org-babel-do-load-languages  'org-babel-load-languages  '((shell . t)))
#+end_src

***** TODO [[https://github.com/rexim/org-cliplink][Insert org-mode links from clipboard]]
:PROPERTIES:
:TITLE:    GitHub - rexim/org-cliplink: Insert org-mode links from clipboard
:URI:      https://github.com/rexim/org-cliplink
:CREATED:  [2023-02-13 Mon 12:45]
:END:
:LOGBOOK:
- State "DONE"       from "TODO"       [2023-08-18 Fri 13:10]
:END:

#+begin_src elisp :tangle no
  (use-package org-cliplink
    :bind
    (("C-x p i" . org-cliplink))
    )
#+end_src

***** TODO Deft

#+begin_src elisp :tangle no
  (use-package deft
    :commands (deft)
    :init
    (defvar deft-extensions '("org"))
    (defvar deft-recursive nil)
    (defvar deft-use-filename-as-title t)
    :config
    (defvar deft-directory org-directory)
    (defvar deft-recursive t)
    (defvar deft-strip-summary-regexp ":PROPERTIES:\n\\(.+\n\\)+:END:\n")
    (defvar deft-use-filename-as-title t)
    :bind  ("C-c n d" . deft)
    )
#+end_src

*** DONE [3/3] Shell
:LOGBOOK:
- State "DONE"       from "TODO"       [2024-07-19 Fri 15:34]
- State "DONE"       from "TODO"       [2024-07-09 Tue 17:11]
:END:
***** DONE Bash completion
:LOGBOOK:
- State "DONE"       from "TODO"       [2024-07-16 Tue 20:35]
- State "DONE"       from "TODO"       [2023-08-18 Fri 13:02]
:END:

#+begin_src elisp
  (use-package bash-completion
    :config
    (require 'bash-completion)
    (bash-completion-setup)
    )
#+end_src

#+begin_src elisp
(defvar shell-dynamic-complete-functions t)
#+end_src

***** DONE [3/3] Eshell
****** CNCL [[https://github.com/szermatt/emacs-bash-completion][Add programmable bash completion to Emacs shell-mode]]
:PROPERTIES:
:TITLE:    GitHub - szermatt/emacs-bash-completion: Add programmable bash completion to Emacs shell-mode
:URI:      https://github.com/szermatt/emacs-bash-completion
:CREATED:  [2023-01-27 Fri 21:00]
:END:
:LOGBOOK:
- State "DONE"       from "TODO"       [2024-02-28 Wed 16:30]
:END:

#+begin_src elisp :tangle no
  (require 'bash-completion)
  (add-hook 'eshell-mode-hook
          (lambda ()
            (add-hook 'completion-at-point-functions
                      'bash-completion-capf-nonexclusive nil t
                      )
            )
          )
#+end_src

****** CNCL Use colors in eshell
     :LOGBOOK:
     - State "DONE"       from "TODO"       [2023-08-28 Mon 18:56]
     :END:


#+begin_src elisp :tangle no
  (use-package xterm-color
    :commands (xterm-color-filter)
    )

  (use-package eshell
    :after xterm-color
    :config
    (define-key eshell-hist-mode-map (kbd "M-r") #'consult-history)
    (add-hook 'eshell-mode-hook
              (lambda ()
                (setenv "TERM" "xterm-256color")))
    (add-hook 'eshell-before-prompt-hook (setq xterm-color-preserve-properties t))
    (add-to-list 'eshell-preoutput-filter-functions 'xterm-color-filter)
    (setq eshell-output-filter-functions
          (remove 'eshell-handle-ansi-color eshell-output-filter-functions)
          )
    )
#+end_src

****** CNCL Eshell completion

#+begin_src elisp :tangle no
  (add-hook 'eshell-mode-hook
          (lambda ()
            (add-hook 'completion-at-point-functions
                      'bash-completion-capf-nonexclusive nil t)))
#+end_src

***** CNCL Emulate A Terminal (EAT)
:LOGBOOK:
- State "CNCL"       from "TODO"       [2024-04-01 Mon 15:52] \\
  Moved to shell and eshell. Eat is not in repositories currently.
- State "DONE"       from              [2023-08-30 Wed 20:43]
:END:

#+begin_src elisp :tangle no
  (use-package eat
    :config
    ;; For `eat-eshell-mode'.
    (add-hook 'eshell-load-hook #'eat-eshell-mode)

    ;; For `eat-eshell-visual-command-mode'.
    (add-hook 'eshell-load-hook #'eat-eshell-visual-command-mode)
    )
#+end_src

*** DONE [2/2] Saving Emacs Sessions
   :LOGBOOK:
   - State "DONE"       from "TODO"       [2024-07-19 Fri 15:08]
   - State "DONE"       from "DONE"       [2024-02-28 Wed 16:26]
   :END:
**** DONE Close frame when done
:LOGBOOK:
- State "DONE"       from "NEXT"       [2023-08-03 Thu 13:21]
:END:

When a server buffer is done, the current window (frame) should be closed. This is useful in scenarios where Emacs is used as an external editor (for instance, from a version control system). When you're done editing, the frame closes automatically. If this is the only frame, Emacs will exit.

#+begin_src elisp
  (add-hook 'server-done-hook (lambda () (delete-frame)))
#+end_src

**** DONE Save desktop session

#+begin_src elisp
  (desktop-save-mode t)
#+end_src

** TODO [8/21] Reading and Writing
:LOGBOOK:
- State "DONE"       from "TODO"       [2023-07-06 Thu 12:32]
:END:

*** DONE Move correctly over camelCased words
:LOGBOOK:
- State "DONE"       from "TODO"       [2024-07-19 Fri 16:04]
:END:

#+begin_src elisp
  (subword-mode)
#+end_src

*** DONE Understand the more common sentence with double space
:LOGBOOK:
- State "DONE"       from "TODO"       [2024-07-19 Fri 16:04]
:END:

#+begin_src elisp
  (setq sentence-end-double-space nil)
#+end_src

*** DONE [[https://pages.sachachua.com/.emacs.d/Sacha.html#orgcb6a264][Join lines into paragraph]]
:LOGBOOK:
- State "DONE"       from "TODO"       [2024-07-19 Fri 16:03]
- State "DONE"       from "TODO"       [2023-07-06 Thu 12:31]
:END:

#+begin_src elisp
  (defun my/fill-or-unfill-paragraph (&optional unfill region)
    "Fill paragraph (or REGION). With the prefix argument UNFILL, fill it instead."
    (interactive (progn
                   (barf-if-buffer-read-only)
                   (list (if current-prefix-arg 'fill) t)))
    (let ((fill-column (if unfill fill-column (point-max))))
      (fill-paragraph nil region)))

  (bind-key "M-q" 'my/fill-or-unfill-paragraph)
#+end_src

#+begin_src elisp
  (defun my/fill-or-unfill-all-paragraphs (&optional unfill)
  "Fill or unfill all paragraphs in the current buffer.
With the prefix argument UNFILL, fill them instead."
  (interactive (list (if current-prefix-arg 'fill)))
  (let ((fill-column (if unfill fill-column (point-max))))
    (save-excursion
      (goto-char (point-min))
      (while (not (eobp))
        (fill-paragraph nil t)
        (forward-paragraph)))))

(bind-key "M-Q" 'my/fill-or-unfill-all-paragraphs)
#+end_src

#+begin_src elisp
  (remove-hook 'text-mode-hook #'turn-on-auto-fill)
  (add-hook 'text-mode-hook 'turn-on-visual-line-mode)
#+end_src

*** TODO Expand some words with auto-correct

  #+begin_src elisp :tangle no
  (setq save-abbrevs 'silently)
  (setq-default abbrev-mode t)
  #+end_src

*** TODO ediff

#+begin_src elisp :tangle no
  (setq ediff-window-setup-function 'ediff-setup-windows-plain)
  (setq ediff-split-window-function 'split-window-horizontally)
#+end_src

*** TODO tramp

#+begin_src elisp :tangle no
  (setq tramp-default-method "ssh"
        tramp-backup-directory-alist backup-directory-alist
        tramp-ssh-controlmaster-options "ssh")
#+end_src

*** TODO [[https://pages.sachachua.com/.emacs.d/Sacha.html#org9d2ca0e][Clean up space]]
:LOGBOOK:
- State "DONE"       from "TODO"       [2023-07-06 Thu 12:32]
:END:

#+begin_src elisp :tangle no
  (bind-key "M-SPC" 'cycle-spacing)
#+end_src

*** TODO Transform <a href> links into org links
:LOGBOOK:
- State "DONE"       from              [2023-08-19 Sat 19:41]
:END:

#+begin_src elisp :tangle no
  (defun my/transform-html-links-to-org ()
  "Transform all HTML <a> links in the current buffer into 'org-mode' links."
  (interactive)
  (goto-char (point-min))
  (while (re-search-forward "<a href=\"\\(.*?\\)\">\\(.*?\\)</a>" nil t)
    (replace-match (org-make-link-string (match-string 1) (match-string 2)))))
#+end_src

*** TODO Count words per minute
:LOGBOOK:
- State "DONE"       from "TODO"       [2023-07-06 Thu 12:32]
:END:

#+begin_src elisp :tangle no
  (require 'org-clock)
  (defun my/org-entry-wpm ()
    (interactive)
    (save-restriction
      (save-excursion
        (org-narrow-to-subtree)
        (goto-char (point-min))
        (let* ((words (count-words-region (point-min) (point-max)))
               (minutes (org-clock-sum-current-item))
               (wpm (/ words minutes)))
          (message "WPM: %d (words: %d, minutes: %d)" wpm words minutes)
          (kill-new (number-to-string wpm))
          )
        )
      )
    )
#+end_src

*** TODO Enable dict mode

  #+begin_src elisp :tangle no
    (setq dictionary-server "automatic")
  #+end_src

*** TODO Pick out passive voice and weasel words
:LOGBOOK:
- State "DONE"       from "NEXT"       [2023-08-09 Wed 13:52]
:END:

#+begin_src elisp :tangle no
  (use-package writegood-mode
    :diminish writegood-mode
    :config
    (progn (add-hook 'text-mode-hook 'writegood-mode))
    )
#+end_src

*** TODO [[https://github.com/ifitzpat/ob-docker-build][Org-babel docker]]
:LOGBOOK:
- State "DONE"       from "TODO"       [2024-07-09 Tue 16:58]
:END:

#+begin_src elisp :tangle no
  (use-package ob-docker-build
    :straight (ob-docker-build :type git :host github :repo "ifitzpat/ob-docker-build")
    :defer t
    :config
    (add-to-list 'org-babel-load-languages '(docker-build . t))
    (org-babel-do-load-languages 'org-babel-load-languages org-babel-load-languages)
  )
#+end_src

*** TODO [1/6] Spelling and syntax
**** DONE Spell checking
:LOGBOOK:
- State "DONE"       from "TODO"       [2024-07-19 Fri 16:51]
- State "DONE"       from "TODO"       [2023-07-05 Wed 16:09]
:END:

This requires installation of hunspell
#+begin_src bash :tangle no
  sudo apt install hunspell
#+end_src

#+begin_src elisp
  (use-package flyspell
    :config (setq ispell-program-name "hunspell"
                  ispell-default-dictionary "en_US"
                  )
    :diminish (flyspell-mode . "φ")
    :hook (text-mode . flyspell-mode)
    :bind (
           ("M-<f7>" . flyspell-buffer)
           ("<f7>" . flyspell-word)
           ("C-;" . flyspell-auto-correct-previous-word)
           )
    )
#+end_src

**** TODO [[https://github.com/d12frosted/flyspell-correct][Flyspell correct]]
:LOGBOOK:
- State "DONE"       from              [2024-07-02 Tue 13:13]
:END:

#+begin_src elisp :tangle no
  (use-package flyspell-correct
    :after flyspell
    :bind (:map flyspell-mode-map ("C-;" . flyspell-correct-wrapper))
  )
#+end_src

**** TODO [[https://www.flycheck.org/][Flycheck]]
:LOGBOOK:
- State "DONE"       from "TODO"       [2024-07-19 Fri 14:30]
- State "DONE"       from "TODO"       [2024-07-02 Tue 13:13]
:END:

Needs external checkers installed

#+begin_src elisp
  (use-package flycheck
    :init (global-flycheck-mode)
    :diminish (flycheck-mode . "")
    :config
    (add-hook 'after-init-hook #'global-flycheck-mode)
    (setq flycheck-emacs-lisp-load-path 'inherit)
    (setq flycheck-emacs-lisp-load-path (concat user-emacs-directory "straight/build"))
    )
#+end_src

**** TODO [[https://github.com/cuonglm/flycheck-checkbashisms][Flycheck bash]]
#+begin_src bash :tangle no
  sudo apt install devscripts
#+end_src

#+begin_src elisp :tangle no
  (use-package flycheck-checkbashisms
    :config
    (flycheck-checkbashisms-setup)
  )
#+end_src

**** TODO [[https://github.com/yoshiki/yaml-mode][Yaml]]
:LOGBOOK:
- State "DONE"       from "TODO"       [2024-06-27 Thu 13:03]
:END:

#+begin_src elisp :tangle no
  (use-package yaml-mode
    :config
    (add-to-list 'auto-mode-alist '("\\.yml\\'" . yaml-mode))
    (add-to-list 'auto-mode-alist '("\\.yaml\\'" . yaml-mode))
    )
#+end_src

**** TODO Docker
:LOGBOOK:
- State "DONE"       from "TODO"       [2024-06-27 Thu 13:03]
:END:
#+begin_src elisp :tangle no
  (use-package docker-compose-mode)
#+end_src

*** DONE [[https://github.com/chenyanming/calibredb.el][Read ebooks]]
:PROPERTIES:
:CREATED:  [2023-01-14 Sat 16:38]
:END:
:LOGBOOK:
- State "DONE"       from "NEXT"       [2023-08-09 Wed 13:27]
:END:

#+begin_src elisp
  (use-package calibredb)
#+end_src

#+begin_src elisp :tangle ~/.emacs.d/custom.el
  (defvar calibredb-root-dir (concat (getenv "HOME") "/library/books"))
  (defvar calibredb-db-dir (expand-file-name "metadata.db" calibredb-root-dir))
  (defvar calibredb-library-alist (concat (getenv "HOME") "/library/books"))
  ;;  (defvar calibredb-search-page-max-rows 1000)

  (defvar calibredb-id-width 6)
  (defvar calibredb-title-width 100)
  (defvar calibredb-format-width 0)
  (defvar calibredb-date-width 0)
  (defvar calibredb-author-width 20)
  (defvar calibredb-comment-width 0)
  (defvar calibredb-tag-width 0)
#+end_src

#+begin_src elisp :tangle ~/.emacs.d/custom.el

  (setq calibredb-format-all-the-icons t)
  (setq calibredb-format-icons-in-terminal t)
#+end_src

Some keybindings

#+begin_src elisp
  (defvar calibredb-show-mode-map
    (let ((map (make-sparse-keymap)))
      (define-key map "?" #'calibredb-entry-dispatch)
      (define-key map "o" #'calibredb-find-file)
      (define-key map "O" #'calibredb-find-file-other-frame)
      (define-key map "V" #'calibredb-open-file-with-default-tool)
      (define-key map "s" #'calibredb-set-metadata-dispatch)
      (define-key map "e" #'calibredb-export-dispatch)
      (define-key map "q" #'calibredb-entry-quit)
      (define-key map "y" #'calibredb-yank-dispatch)
      (define-key map "," #'calibredb-quick-look)
      (define-key map "." #'calibredb-dired-open)
      (define-key map "\M-/" #'calibredb-rga)
      (define-key map "\M-t" #'calibredb-set-metadata--tags)
      (define-key map "\M-a" #'calibredb-set-metadata--author_sort)
      (define-key map "\M-A" #'calibredb-set-metadata--authors)
      (define-key map "\M-T" #'calibredb-set-metadata--title)
      (define-key map "\M-c" #'calibredb-set-metadata--comments)
      map)
    "Keymap for `calibredb-show-mode'.")
#+end_src

#+begin_src elisp
  (defvar calibredb-search-mode-map
    (let ((map (make-sparse-keymap)))
      (define-key map [mouse-3] #'calibredb-search-mouse)
      (define-key map (kbd "<RET>") #'calibredb-find-file)
      (define-key map "?" #'calibredb-dispatch)
      (define-key map "a" #'calibredb-add)
      (define-key map "A" #'calibredb-add-dir)
      (define-key map "c" #'calibredb-clone)
      (define-key map "d" #'calibredb-remove)
      (define-key map "D" #'calibredb-remove-marked-items)
      (define-key map "j" #'calibredb-next-entry)
      (define-key map "k" #'calibredb-previous-entry)
      (define-key map "l" #'calibredb-virtual-library-list)
      (define-key map "L" #'calibredb-library-list)
      (define-key map "n" #'calibredb-virtual-library-next)
      (define-key map "N" #'calibredb-library-next)
      (define-key map "p" #'calibredb-virtual-library-previous)
      (define-key map "P" #'calibredb-library-previous)
      (define-key map "s" #'calibredb-set-metadata-dispatch)
      (define-key map "S" #'calibredb-switch-library)
      (define-key map "o" #'calibredb-find-file)
      (define-key map "O" #'calibredb-find-file-other-frame)
      (define-key map "v" #'calibredb-view)
      (define-key map "V" #'calibredb-open-file-with-default-tool)
      (define-key map "," #'calibredb-quick-look)
      (define-key map "." #'calibredb-dired-open)
      (define-key map "y" #'calibredb-yank-dispatch)
      (define-key map "b" #'calibredb-catalog-bib-dispatch)
      (define-key map "e" #'calibredb-export-dispatch)
      (define-key map "r" #'calibredb-search-refresh-and-clear-filter)
      (define-key map "R" #'calibredb-search-clear-filter)
      (define-key map "q" #'calibredb-search-quit)
      (define-key map "m" #'calibredb-mark-and-forward)
      (define-key map "f" #'calibredb-toggle-favorite-at-point)
      (define-key map "x" #'calibredb-toggle-archive-at-point)
      (define-key map "h" #'calibredb-toggle-highlight-at-point)
      (define-key map "u" #'calibredb-unmark-and-forward)
      (define-key map "i" #'calibredb-edit-annotation)
      (define-key map (kbd "<DEL>") #'calibredb-unmark-and-backward)
      (define-key map (kbd "<backtab>") #'calibredb-toggle-view)
      (define-key map (kbd "TAB") #'calibredb-toggle-view-at-point)
      (define-key map "\M-n" #'calibredb-show-next-entry)
      (define-key map "\M-p" #'calibredb-show-previous-entry)
      (define-key map "/" #'calibredb-search-live-filter)
      (define-key map "\M-t" #'calibredb-set-metadata--tags)
      (define-key map "\M-a" #'calibredb-set-metadata--author_sort)
      (define-key map "\M-A" #'calibredb-set-metadata--authors)
      (define-key map "\M-T" #'calibredb-set-metadata--title)
      (define-key map "\M-c" #'calibredb-set-metadata--comments)
      map)
    "Keymap for `calibredb-search-mode'.")
#+end_src

*** DONE Annotate [[https://github.com/org-noter/org-noter][PDFs and EPUBs]]
:LOGBOOK:
- State "DONE"       from "TODO"       [2024-07-19 Fri 14:35]
- State "DONE"       from "NEXT"       [2023-08-09 Wed 15:06]
:END:
#+begin_src elisp
  (use-package org-noter)
#+end_src

#+begin_src elisp :tangle ~/.emacs.d/custom.el
  (defvar org-noter-notes-search-path (list (concat org-directory "/library/books")))
  (defvar org-noter-default-notes-file-names '("books.org"))  
#+end_src

*** DONE [[https://github.com/fuxialexander/org-pdftools][Link PDFs]]

:PROPERTIES:
:TITLE:    GitHub - fuxialexander/org-pdftools: A custom org link type for pdf-tools
:URI:      https://github.com/fuxialexander/org-pdftools
:CREATED:  [2023-01-28 Sat 11:04]
:END:
:LOGBOOK:
- State "DONE"       from "TODO"       [2024-07-19 Fri 16:54]
- State "DONE"       from "NEXT"       [2023-08-12 Sat 14:05]
:END:

#+begin_src elisp
  (use-package org-noter-pdftools
    :after org-noter
    :config
    ;; Add a function to ensure precise note is inserted
    (defun org-noter-pdftools-insert-precise-note (&optional toggle-no-questions)
      (interactive "P")
      (org-noter--with-valid-session
       (let ((org-noter-insert-note-no-questions (if toggle-no-questions
  						   (not org-noter-insert-note-no-questions)
                                                   org-noter-insert-note-no-questions))
             (org-pdftools-use-isearch-link t)
             (org-pdftools-use-freepointer-annot t))
         (org-noter-insert-note (org-noter--get-precise-info)))))

    ;; fix https://github.com/weirdNox/org-noter/pull/93/commits/f8349ae7575e599f375de1be6be2d0d5de4e6cbf
    (defun org-noter-set-start-location (&optional arg)
      "When opening a session with this document, go to the current location.
  With a prefix ARG, remove start location."
      (interactive "P")
      (org-noter--with-valid-session
       (let ((inhibit-read-only t)
             (ast (org-noter--parse-root))
             (location (org-noter--doc-approx-location (when (called-interactively-p 'any) 'interactive))))
         (with-current-buffer (org-noter--session-notes-buffer session)
           (org-with-wide-buffer
            (goto-char (org-element-property :begin ast))
            (if arg
                (org-entry-delete nil org-noter-property-note-location)
              (org-entry-put nil org-noter-property-note-location
                             (org-noter--pretty-print-location location))))))))
    (with-eval-after-load 'pdf-annot
      (add-hook 'pdf-annot-activate-handler-functions #'org-noter-pdftools-jump-to-note)
      )
    )
#+end_src

*** DONE [[https://depp.brause.cc/nov.el/][View EPUBs]]               :books:
:LOGBOOK:
- State "DONE"       from "TODO"       [2024-07-19 Fri 14:37]
- State "DONE"       from "NEXT"       [2023-08-09 Wed 13:19]
:END:
#+begin_src elisp
  (use-package nov
    :config
    (add-to-list 'auto-mode-alist '("\\.epub\\'" . nov-mode))
    )
#+end_src

*** TODO [[https://github.com/tmalsburg/helm-bibtex][Zotero]]
#+begin_src elisp :tangle no
  (use-package helm-bibtex)
#+end_src

#+begin_src elisp :tangle ~/.emacs.d/custom.el
  (defvar bibtex-completion-bibliography '("~/bibliography/zotero.bib"))
#+end_src

** DONE [2/2] Security
:LOGBOOK:
- State "DONE"       from "TODO"       [2024-07-16 Tue 21:49]
- State "DONE"       from "TODO"       [2024-07-09 Tue 14:16]
:END:
*** DONE Password-store
:LOGBOOK:
- State "DONE"       from "TODO"       [2024-07-16 Tue 21:49]
- State "DONE"       from "TODO"       [2023-07-06 Thu 11:44]
:END:
#+begin_src elisp
  (use-package password-store)
#+end_src

*** DONE Auth source
:LOGBOOK:
- State "DONE"       from "TODO"       [2023-07-06 Thu 11:45]
:END:
#+begin_src elisp
  (use-package auth-source
    :config (auth-source-pass-enable)
    )
#+end_src

** TODO [2/3] AI
*** DONE [[https://github.com/s-kostyaev/ellama][Ellama]]
:LOGBOOK:
- State "DONE"       from "TODO"       [2024-07-19 Fri 17:27]
- State "DONE"       from "TODO"       [2024-06-27 Thu 07:40]
:END:

#+begin_src elisp
  ;; YOU DON'T NEED NONE OF THIS CODE FOR SIMPLE INSTALL
  ;; IT IS AN EXAMPLE OF CUSTOMIZATION.
  (use-package ellama
    :init
    (require 'llm-openai)
    ;; setup key bindings
    (setq ellama-keymap-prefix "C-c e")
    )
#+end_src

#+begin_src elisp ~/.emacs.d/custom.el
     ;; language you want ellama to translate to
     (setq ellama-language "English")
     (setq ellama-sessions-directory (concat org-directory "/ellama-sessions"))
     (setq ellama-providers
           '(
             ("openai" .  (make-llm-openai
                           :key (auth-source-pass-get "api-key" "www/openai.com/amr@gharbeia.net")
                           :chat-model "gpt-4o"
                           :embedding-model "text-embedding-3-large")
  	    )
             ("groq" .  (make-llm-openai-compatible
                         :url "https://api.groq.com/openai/v1"
                         :key (auth-source-pass-get "api-key" "www/console.groq.com/groq@amr.gharbeia.net")
                         :chat-model "deepseek-r1-distill-llama-70b"
                         :embedding-model "deepseek-r1-distill-llama-70b")
  	    )
             )
           )
  (setq ellama-provider "groq")
  (setq ellama-translation-provider "groq")
  (setq ellama-naming-provider "groq")
  (setq ellama-naming-scheme 'ellama-generate-name-by-llm)
#+end_src

*** CNCL GPTel
   :LOGBOOK:
   - State "CNCL"       from "DONE"       [2024-04-01 Mon 15:32] \\
     Moved to Ellama
   - State "DONE"       from "TODO"       [2024-02-28 Wed 16:49]
   :END:
   #+begin_src elisp :tangle no
     (use-package gptel)
   #+end_src

   #+begin_src elisp :tangle no
     (setq gptel-api-key (auth-source-pass-get "api-key" "www/openai.com/amr@gharbeia.net"))
   #+end_src

*** TODO [[https://github.com/s-kostyaev/elisa][Elisa]]

#+begin_src elisp :tangle no
  (use-package elisa
    :init
    (setopt elisa-limit 5)
    (require 'llm-ollama)
    (setopt elisa-embeddings-provider (make-llm-ollama :embedding-model "nomic-embed-text"))
    (setopt elisa-chat-provider (make-llm-ollama
                                 :chat-model "sskostyaev/openchat:8k-rag"
                                 :embedding-model "nomic-embed-text"))
    )
#+end_src

** DONE [[https://github.com/beancount/beancount-mode/][Accounting]]
:LOGBOOK:
- State "DONE"       from "TODO"       [2024-07-19 Fri 15:07]
- State "DONE"       from "TODO"       [2024-06-27 Thu 07:43]
:END:

#+begin_src elisp
  (use-package beancount
    :straight (beancount :type git :host github :repo "beancount/beancount-mode")
    :config
    (add-to-list 'auto-mode-alist '("\\.beancount\\'" . beancount-mode))
    (add-hook 'beancount-mode-hook #'outline-minor-mode)
    (define-key beancount-mode-map (kbd "C-c C-n") #'outline-next-visible-heading)
    (define-key beancount-mode-map (kbd "C-c C-p") #'outline-previous-visible-heading)
    (add-hook 'beancount-mode-hook #'flymake-bean-check-enable)
    )
#+end_src

On package.el, it is a manual install so far

#+begin_src elisp :tangle no
  (make-directory (expand-file-name "manual-packages/" user-emacs-directory) t)
  (make-directory (expand-file-name "beancount/" (concat user-emacs-directory "manual-packages")) t)
  (add-to-list 'load-path "~/.emacs.d/manual-packages/beancount-mode")
  (require 'beancount)
  (add-to-list 'auto-mode-alist '("\\.beancount\\'" . beancount-mode))
  (add-hook 'beancount-mode-hook #'outline-minor-mode)
  (define-key beancount-mode-map (kbd "C-c C-n") #'outline-next-visible-heading)
  (define-key beancount-mode-map (kbd "C-c C-p") #'outline-previous-visible-heading)
  (add-hook 'beancount-mode-hook #'flymake-bean-check-enable)
  #+end_src

#+begin_src bash :tangle no
  cd ~/.emacs.d/manual-packages/
  git clone https://github.com/beancount/beancount-mode/
#+end_src

** DONE Browser
:LOGBOOK:
- State "DONE"       from "TODO"       [2024-07-19 Fri 17:28]
- State "DONE"       from "TODO"       [2023-07-07 Fri 15:29]
:END:
#+begin_src elisp
  (use-package eww
    :bind* (("M-m g x" . eww)
            ("M-m g :" . eww-browse-with-external-browser)
            ("M-m g #" . eww-list-histories)
            ("M-m g {" . eww-back-url)
            ("M-m g }" . eww-forward-url))
    :config
    (progn
      (add-hook 'eww-mode-hook 'visual-line-mode)
      )
    )
#+end_src

** DONE [[https://github.com/Silex/docker.el][Manage Docker in Emacs]]
:LOGBOOK:
- State "DONE"       from "TODO"       [2024-07-19 Fri 17:29]
:END:

#+begin_src elisp
  (use-package docker
    :bind ("C-c d" . docker)
    )
#+end_src

** DONE [[https://github.com/sergiruiztrepat/chemtable][Periodic table of the elements]]                            :chemistry:
:PROPERTIES:
:CREATED:  [2023-01-27 Fri 21:12]
:TITLE:    GitHub - sergiruiztrepat/chemtable: Periodic table of the elements
:URI:      https://github.com/sergiruiztrepat/chemtable
:END:
:LOGBOOK:
- State "DONE"       from "TODO"       [2024-07-19 Fri 17:29]
- State "DONE"       from "TODO"       [2023-08-21 Mon 13:27]
:END:

#+begin_src elisp
  (use-package chemtable)
#+end_src

** DONE End matter
#+begin_src elisp
  (provide 'config)
  ;;; config.el ends here
#+end_src

#+begin_src elisp :tangle ~/.emacs.d/custom.el
  (provide 'custom)
  ;;; custom.el ends here
#+end_src

* TODO [1/59] Reorganize this file to follow Emacs manual
:PROPERTIES:
:CREATED:  [2023-07-12 Wed 21:37]
:END:
**** TODO Distribution
**** TODO Introduction
**** TODO [0/4] 1 The Organization of the Screen
***** TODO 1.1 Point
***** TODO 1.2 The Echo Area
***** TODO 1.3 The Mode Line
***** TODO 1.4 The Menu Bar
**** TODO 2 Kinds of User Input
**** TODO 3 Keys
**** TODO 4 Keys and Commands
**** TODO 5 Entering Emacs
**** TODO 6 Exiting Emacs
**** TODO [1/11] 7 Basic Editing Commands
***** CNCL 7.1 Inserting Text
:LOGBOOK:
- State "CNCL"       from "TODO"       [2024-07-29 Mon 16:24]
:END:
***** TODO 7.2 Changing the Location of Point
***** TODO 7.3 Erasing
***** TODO 7.4 Undoing Changes
***** TODO 7.5 Files
***** TODO 7.6 Help
***** TODO 7.7 Blank Lines
***** TODO 7.8 Continuation Lines
***** TODO 7.9 Cursor Position Information
***** TODO 7.10 Numeric Arguments
***** TODO 7.11 Repeating a Command
**** TODO [2/8] 8 The Minibuffer
***** TODO 8.1 Using the Minibuffer
***** TODO 8.2 Minibuffers for File Names
***** TODO 8.3 Editing in the Minibuffer
***** TODO [2/8] 8.4 Completion
****** TODO 8.4.1 Completion Example
****** TODO 8.4.2 Completion Commands
****** TODO 8.4.3 Completion Exit
****** TODO 8.4.4 How Completion Alternatives Are Chosen
****** TODO 8.4.5 Completion Options
****** TODO [0/1] Company
:LOGBOOK:
- State "DONE"       from "TODO"       [2023-07-05 Wed 16:46]
:END:
#+begin_src elisp :tangle no
  (use-package company
    :diminish company-mode
    :config
    (defvar company-minimum-prefix-length 3)
    (defvar company-idle-delay 0)
    (defvar company-global-modes t)
    (defvar company-selection-wrap-around t)
    (defvar company-tooltip-align-annotations t)
    (defvar company-backends '((
                              company-capf
                              company-dabbrev-code
                              company-dabbrev
                              company-ispell
                              company-files
                              company-web
                              company-shell
                              company-posframe
                              )))

    (global-company-mode)
    (add-hook 'after-init-hook 'global-company-mode)
    (add-hook 'after-init-hook 'company-tng-mode)

    (global-set-key (kbd "<tab>") #'company-indent-or-complete-common)
    (global-set-key (kbd "C-c C-/") #'company-other-backend)

    (with-eval-after-load 'company
      (define-key company-active-map (kbd "M-/") #'company-complete))

    (with-eval-after-load 'company
      (define-key company-active-map
        (kbd "TAB")
        #'company-complete-common-or-cycle)
      (define-key company-active-map
        (kbd "<backtab>")
        (lambda ()
          (interactive)
          (company-complete-common-or-cycle -1))))
    )
  #+end_src
  
#+begin_src elisp :tangle no
  (use-package company-shell
    :after company
    :config
    (add-to-list 'company-backends '(company-shell
                                     company-shell-env
                                     company-fish-shell
                                     )
                 )
    (setq company-transformers '(delete-consecutive-dups
                                 company-sort-by-occurrence))

    )
#+end_src

#+begin_src elisp :tangle no
  (use-package company-capf
    :after company
    :config
    (add-to-list 'company-backends '(company-capf))
    )
#+end_src

#+begin_src elisp :tangle no
  (use-package company-ispell
    :after company
    )
  (add-to-list 'company-backends '(company-ispell))
#+end_src

#+begin_src elisp :tangle no
  (use-package company-files
    :after company
    )
  (add-to-list 'company-backends '(company-files))
#+end_src

******* TODO Required for proportional font
:LOGBOOK:
- State "DONE"       from "TODO"       [2023-07-05 Wed 16:46]
:END:
#+begin_src elisp :tangle no
  (use-package company-posframe
    :diminish company-posframe-mode
    :config (company-posframe-mode)
    )
#+end_src

****** DONE [5/5] [[https://tuhdo.github.io/helm-intro.html][Helm]]
:LOGBOOK:
- State "DONE"       from "NEXT"       [2023-08-18 Fri 12:57]
:END:

******* CNCL Basic Helm
#+begin_src elisp :tangle no
  (use-package helm
    :init (helm-mode)
    :config
    (defvar helm-M-x-fuzzy-match t)
    (defvar helm-recentf-fuzzy-match t)
    (defvar helm-buffers-fuzzy-matching t)
    (defvar helm-locate-fuzzy-match t)
    (defvar helm-mode-fuzzy-match t)
    (defvar helm-split-window-inside-p nil) ; open helm buffer inside current window, not occupy whole other window
    (defvar helm-lisp-fuzzy-completion t)
    :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

******* CNCL Interface to silversearch-ag for fast search among entire folders
    :LOGBOOK:
    - State "DONE"       from "TODO"       [2024-02-12 Mon 16:13]
    :END:

#+begin_src elisp :tangle no
  (use-package helm-ag)
#+end_src

******* CNCL [[https://github.com/emacs-helm/helm-firefox][Display firefox bookmarks with emacs helm interface]] :emacs:web:archive:
:PROPERTIES:
:TITLE:    GitHub - emacs-helm/helm-firefox: Display firefox bookmarks with emacs helm interface
:URI:      tps://github.com/emacs-helm/helm-firefox
:CREATED:  [2023-01-28 Sat 09:11]
:END:
:LOGBOOK:
- State "CNCL"   from "TODO"       [2023-08-18 Fri 12:56] \\
  Not using Firefox bookmarks for now.
:END:

#+begin_src elisp :tangle no
  (use-package helm-firefox)
#+end_src

******* CNCL Allow refiling to level, override Helm to complete refiling target
:LOGBOOK:
- State "DONE"       from "TODO"       [2023-07-07 Fri 16:50]
:END:
#+begin_src elisp :tangle no
  (setq org-refile-use-outline-path 'file)
#+end_src

******* CNCL Shell history
:LOGBOOK:
- State "DONE"       from "TODO"       [2023-08-18 Fri 13:01]
:END:

#+begin_src elisp :tangle no
  (use-package helm-shell-history)
#+end_src

****** DONE [5/5] [[https://kristofferbalintona.me/posts/202202211546/][Vertico, Marginalia, All-the-icons-completion, and Orderless]]
:LOGBOOK:
- State "DONE"       from "DONE"       [2024-07-19 Fri 14:12]
- State "DONE"       from "TODO"       [2024-07-19 Fri 13:56]
:END:
******* DONE [[https://github.com/minad/vertico][Vertico]]
:LOGBOOK:
- State "DONE"       from "TODO"       [2024-07-19 Fri 13:34]
:END:

#+begin_src elisp
  (use-package vertico
    :demand t                             ; Otherwise won't get loaded immediately
    :init  (vertico-mode)
    :straight (vertico :files (:defaults "extensions/*") ; Special recipe to load extensions conveniently
                       :includes (vertico-indexed
                                  vertico-flat
                                  vertico-grid
                                  vertico-mouse
                                  vertico-quick
                                  vertico-buffer
                                  vertico-repeat
                                  vertico-reverse
                                  vertico-directory
                                  vertico-multiform
                                  vertico-unobtrusive
                                  ))

   :config
   (setq vertico-cycle t)
   (setq vertico-count 13)
   (setq vertico-resize nil)
   (setq vertico-cycle nil)

   ;; Extensions
    (setq vertico-grid-separator "       ")
    (setq vertico-grid-lookahead 50)
    (setq vertico-buffer-display-action '(display-buffer-reuse-window))
    (setq vertico-multiform-categories
  	'((file reverse)
  	  (consult-grep buffer)
  	  (consult-location)
  	  (imenu buffer)
  	  (library reverse indexed)
  	  (org-roam-node reverse indexed)
  	  (t reverse)
  	  )
  	)
    (setq vertico-multiform-commands
  	'(("flyspell-correct-*" grid reverse)
  	  (org-refile grid reverse indexed)
  	  (consult-yank-pop indexed)
  	  (consult-flycheck)
  	  (consult-lsp-diagnostics)
  	  )
  	)

  ;; Extensions
  (vertico-multiform-mode)

  :bind (:map vertico-map
  	    ("C-j" . vertico-next)
  	    ("C-k" . vertico-previous)
  	    ("C-f" . vertico-exit)
  	    :map minibuffer-local-map
  	    ("M-h" . backward-kill-word))
  )
#+end_src

#+begin_src elisp
  (use-package savehist
    :init
    (savehist-mode)
    )
#+end_src

#+begin_src elisp
;; A few more useful configurations...
(use-package emacs
  :custom
  ;; Support opening new minibuffers from inside existing minibuffers.
  (enable-recursive-minibuffers t)
  ;; Emacs 28 and newer: Hide commands in M-x which do not work in the current
  ;; mode.  Vertico commands are hidden in normal buffers. This setting is
  ;; useful beyond Vertico.
  (read-extended-command-predicate #'command-completion-default-include-p)
  :init
  ;; Add prompt indicator to `completing-read-multiple'.
  ;; We display [CRM<separator>], e.g., [CRM,] if the separator is a comma.
  (defun crm-indicator (args)
    (cons (format "[CRM%s] %s"
                  (replace-regexp-in-string
                   "\\`\\[.*?]\\*\\|\\[.*?]\\*\\'" ""
                   crm-separator)
                  (car args))
          (cdr args)))
  (advice-add #'completing-read-multiple :filter-args #'crm-indicator)

  ;; Do not allow the cursor in the minibuffer prompt
  (setq minibuffer-prompt-properties
        '(read-only t cursor-intangible t face minibuffer-prompt))
  (add-hook 'minibuffer-setup-hook #'cursor-intangible-mode))
#+end_src

******* DONE [[https://github.com/minad/marginalia/][Marginalia]]
:LOGBOOK:
- State "DONE"       from "TODO"       [2024-07-19 Fri 13:35]
:END:

#+begin_src elisp
  (use-package marginalia
    :init
    (marginalia-mode)
    :config
    (setq marginalia-max-relative-age 0)
    (setq marginalia-align 'right)
    :bind (("M-A" . marginalia-cycle)
  	 :map minibuffer-local-map
  	 ("M-A" . marginalia-cycle))
    )
#+end_src

******* DONE [[https://github.com/oantolin/orderless][Orderless]]

Seast space separated words with no order.

#+begin_src elisp
  (use-package orderless
    :config
    (setq completion-styles '(orderless basic))
    (setq completion-category-overrides '((file (styles basic partial-completion))))
    )
#+end_src

******* DONE [[https://github.com/minad/consult][Consult]]
:LOGBOOK:
- State "DONE"       from "TODO"       [2024-07-19 Fri 13:35]
:END:

#+begin_src elisp
  ;; Example configuration for Consult
(use-package consult
  ;; Replace bindings. Lazily loaded by `use-package'.
  :bind (;; C-c bindings in `mode-specific-map'
         ("C-c M-x" . consult-mode-command)
         ("C-c h" . consult-history)
         ("C-c k" . consult-kmacro)
         ("C-c m" . consult-man)
         ("C-c i" . consult-info)
         ([remap Info-search] . consult-info)
         ;; C-x bindings in `ctl-x-map'
         ("C-x M-:" . consult-complex-command)     ;; orig. repeat-complex-command
         ("C-x b" . consult-buffer)                ;; orig. switch-to-buffer
         ("C-x 4 b" . consult-buffer-other-window) ;; orig. switch-to-buffer-other-window
         ("C-x 5 b" . consult-buffer-other-frame)  ;; orig. switch-to-buffer-other-frame
         ("C-x t b" . consult-buffer-other-tab)    ;; orig. switch-to-buffer-other-tab
         ("C-x r b" . consult-bookmark)            ;; orig. bookmark-jump
         ("C-x p b" . consult-project-buffer)      ;; orig. project-switch-to-buffer
         ;; Custom M-# bindings for fast register access
         ("M-#" . consult-register-load)
         ("M-'" . consult-register-store)          ;; orig. abbrev-prefix-mark (unrelated)
         ("C-M-#" . consult-register)
         ;; Other custom bindings
         ("M-y" . consult-yank-pop)                ;; orig. yank-pop
         ;; M-g bindings in `goto-map'
         ("M-g e" . consult-compile-error)
         ("M-g f" . consult-flymake)               ;; Alternative: consult-flycheck
         ("M-g g" . consult-goto-line)             ;; orig. goto-line
         ("M-g M-g" . consult-goto-line)           ;; orig. goto-line
         ("M-g o" . consult-outline)               ;; Alternative: consult-org-heading
         ("M-g m" . consult-mark)
         ("M-g k" . consult-global-mark)
         ("M-g i" . consult-imenu)
         ("M-g I" . consult-imenu-multi)
         ;; M-s bindings in `search-map'
         ("M-s d" . consult-find)                  ;; Alternative: consult-fd
         ("M-s c" . consult-locate)
         ("M-s g" . consult-grep)
         ("M-s G" . consult-git-grep)
         ("M-s r" . consult-ripgrep)
         ("M-s l" . consult-line)
         ("M-s L" . consult-line-multi)
         ("M-s k" . consult-keep-lines)
         ("M-s u" . consult-focus-lines)
         ;; Isearch integration
         ("M-s e" . consult-isearch-history)
         :map isearch-mode-map
         ("M-e" . consult-isearch-history)         ;; orig. isearch-edit-string
         ("M-s e" . consult-isearch-history)       ;; orig. isearch-edit-string
         ("M-s l" . consult-line)                  ;; needed by consult-line to detect isearch
         ("M-s L" . consult-line-multi)            ;; needed by consult-line to detect isearch
         ;; Minibuffer history
         :map minibuffer-local-map
         ("M-s" . consult-history)                 ;; orig. next-matching-history-element
         ("M-r" . consult-history))                ;; orig. previous-matching-history-element

  ;; Enable automatic preview at point in the *Completions* buffer. This is
  ;; relevant when you use the default completion UI.
  :hook (completion-list-mode . consult-preview-at-point-mode)

  ;; The :init configuration is always executed (Not lazy)
  :init

  ;; Optionally configure the register formatting. This improves the register
  ;; preview for `consult-register', `consult-register-load',
  ;; `consult-register-store' and the Emacs built-ins.
  (setq register-preview-delay 0.5
        register-preview-function #'consult-register-format)

  ;; Optionally tweak the register preview window.
  ;; This adds thin lines, sorting and hides the mode line of the window.
  (advice-add #'register-preview :override #'consult-register-window)

  ;; Use Consult to select xref locations with preview
  (setq xref-show-xrefs-function #'consult-xref
        xref-show-definitions-function #'consult-xref)

  ;; Configure other variables and modes in the :config section,
  ;; after lazily loading the package.
  :config

  ;; Optionally configure preview. The default value
  ;; is 'any, such that any key triggers the preview.
  ;; (setq consult-preview-key 'any)
  ;; (setq consult-preview-key "M-.")
  ;; (setq consult-preview-key '("S-<down>" "S-<up>"))
  ;; For some commands and buffer sources it is useful to configure the
  ;; :preview-key on a per-command basis using the `consult-customize' macro.
  (consult-customize
   consult-theme :preview-key '(:debounce 0.2 any)
   consult-ripgrep consult-git-grep consult-grep
   consult-bookmark consult-recent-file consult-xref
   consult--source-bookmark consult--source-file-register
   consult--source-recent-file consult--source-project-recent-file
   ;; :preview-key "M-."
   :preview-key '(:debounce 0.4 any))

  ;; Optionally configure the narrowing key.
  ;; Both < and C-+ work reasonably well.
  (setq consult-narrow-key "<") ;; "C-+"

  ;; Optionally make narrowing help available in the minibuffer.
  ;; You may want to use `embark-prefix-help-command' or which-key instead.
  ;; (keymap-set consult-narrow-map (concat consult-narrow-key " ?") #'consult-narrow-help)
)
#+end_src

******* DONE All the icons completion
:LOGBOOK:
- State "DONE"       from "TODO"       [2024-07-19 Fri 13:35]
:END:

#+begin_src elisp
  (use-package all-the-icons-completion
  :after (marginalia all-the-icons)
  :hook (marginalia-mode . all-the-icons-completion-marginalia-setup)
  :init
  (all-the-icons-completion-mode)
  )
#+end_src

***** TODO 8.5 Minibuffer History
***** DONE 8.6 Repeating Minibuffer Commands
:LOGBOOK:
- State "DONE"       from "TODO"       [2024-07-24 Wed 11:30]
:END:

Instead of C-x o, C-x o, C-x o, you can use C-x o o o.

#+begin_src elisp
  (repeat-mode)
#+end_src

***** TODO 8.7 Entering passwords
***** DONE 8.8 Yes or No Prompts
:LOGBOOK:
- State "DONE"       from "TODO"       [2024-07-24 Wed 11:30]
:END:

#+begin_src elisp
  (defalias 'yes-or-no-p 'y-or-n-p)
#+end_src

**** TODO 9 Running Commands by Name
**** TODO [1/11] 10 Help
***** DONE Add ~/org/info to when searching for INFO documentation after Info-mode has started

 #+begin_src elisp
   (add-hook 'info-mode-hook
             (lambda ()
               (defvar info-additional-directory-list (concat org-directory "/info"))
               )
             )

   (global-set-key (kbd "C-c l") #'dictionary-lookup-definition)
#+end_src

***** TODO 10.1 Help Summary
***** TODO 10.2 Documentation for a Key
***** TODO 10.3 Help by Command or Variable Name
***** TODO 10.4 Apropos
***** TODO 10.5 Help Mode Commands
***** TODO 10.6 Keyword Search for Packages
***** TODO 10.7 Help for International Language Support
***** TODO 10.8 Other Help Commands
***** TODO 10.9 Help Files
***** TODO 10.10 Help on Active Text and Tooltips
**** TODO [0/7] 11 The Mark and the Region
***** TODO 11.1 Setting the Mark
***** TODO 11.2 Commands to Mark Textual Objects
***** TODO 11.3 Operating on the Region
***** TODO 11.4 The Mark Ring
***** TODO 11.5 The Global Mark Ring
***** TODO 11.6 Shift Selection
***** TODO 11.7 Disabling Transient Mark Mode
**** TODO [0/6] 12 Killing and Moving Text
***** TODO [0/4] 12.1 Deletion and Killing
****** TODO 12.1.1 Deletion
****** TODO 12.1.2 Killing by Lines
****** TODO 12.1.3 Other Kill Commands
****** TODO 12.1.4 Options for Killing
***** TODO [0/3] 12.2 Yanking
****** TODO 12.2.1 The Kill Ring
****** TODO 12.2.2 Yanking Earlier Kills
****** TODO 12.2.3 Appending Kills
***** TODO [0/3] 12.3 “Cut and Paste” Operations on Graphical Displays
****** TODO 12.3.1 Using the Clipboard
****** TODO 12.3.2 Cut and Paste with Other Window Applications
****** TODO 12.3.3 Secondary Selection
***** TODO 12.4 Accumulating Text
***** TODO 12.5 Rectangles
***** TODO 12.6 CUA Bindings
**** TODO [0/8] 13 Registers
***** TODO 13.1 Saving Positions in Registers
***** TODO 13.2 Saving Text in Registers
***** TODO 13.3 Saving Rectangles in Registers
***** TODO 13.4 Saving Window Configurations in Registers
***** TODO 13.5 Keeping Numbers in Registers
***** TODO 13.6 Keeping File Names in Registers
***** TODO 13.7 Keyboard Macro Registers
***** TODO 13.8 Bookmarks
**** TODO [0/23] 14 Controlling the Display
***** TODO 14.1 Scrolling
***** TODO 14.2 Recentering
***** TODO 14.3 Automatic Scrolling
***** TODO 14.4 Horizontal Scrolling
***** TODO 14.5 Narrowing
***** TODO 14.6 View Mode
***** TODO 14.7 Follow Mode
***** TODO 14.8 Text Faces
***** TODO [0/2] 14.9 Colors for Faces
****** TODO 14.9.1 Color Names
****** TODO 14.9.2 RGB Triplets
***** TODO 14.10 Standard Faces
***** TODO 14.11 Text Scale
***** TODO 14.12 Font Lock mode
***** TODO 14.13 Interactive Highlighting
***** TODO 14.14 Window Fringes
***** TODO 14.15 Displaying Boundaries
***** TODO 14.16 Useless Whitespace
***** TODO 14.17 Selective Display
***** TODO 14.18 Optional Mode Line Features
***** TODO 14.19 How Text Is Displayed
***** TODO 14.20 Displaying the Cursor
***** TODO 14.21 Line Truncation
***** TODO 14.22 Visual Line Mode
***** TODO 14.23 Customization of Display
**** TODO [0/12] 15 Searching and Replacement
***** TODO [0/7] 15.1 Incremental Search
****** TODO 15.1.1 Basics of Incremental Search
****** TODO 15.1.2 Repeating Incremental Search
****** TODO 15.1.3 Isearch Yanking
****** TODO 15.1.4 Errors in Incremental Search
****** TODO 15.1.5 Special Input for Incremental Search
****** TODO 15.1.6 Not Exiting Incremental Search
****** TODO 15.1.7 Searching the Minibuffer
***** TODO 15.2 Nonincremental Search
***** TODO 15.3 Word Search
***** TODO 15.4 Symbol Search
***** TODO 15.5 Regular Expression Search
***** TODO 15.6 Syntax of Regular Expressions
***** TODO 15.7 Backslash in Regular Expressions
***** TODO 15.8 Regular Expression Example
***** TODO 15.9 Lax Matching During Searching
***** TODO [0/4] 15.10 Replacement Commands
****** TODO 15.10.1 Unconditional Replacement
****** TODO 15.10.2 Regexp Replacement
****** TODO 15.10.3 Replace Commands and Lax Matches
****** TODO 15.10.4 Query Replace
***** TODO 15.11 Other Search-and-Loop Commands
***** TODO 15.12 Tailoring Search to Your Needs
**** TODO [0/4] 16 Commands for Fixing Typos
***** TODO 16.1 Undo
***** TODO 16.2 Transposing Text
***** TODO 16.3 Case Conversion
***** TODO 16.4 Checking and Correcting Spelling
**** TODO [0/7] 17 Keyboard Macros
***** TODO 17.1 Basic Use
***** TODO 17.2 The Keyboard Macro Ring
***** TODO 17.3 The Keyboard Macro Counter
***** TODO 17.4 Executing Macros with Variations
***** TODO 17.5 Naming and Saving Keyboard Macros
***** TODO 17.6 Editing a Keyboard Macro
****** TODO 17.7 Stepwise Editing a Keyboard Macro
**** TODO [7/29] 18 File Handling
***** TODO 18.1 File Names
***** TODO 18.2 Visiting Files
***** TODO [0/6] 18.3 Saving Files
****** TODO 18.3.1 Commands for Saving Files
****** TODO [0/3] 18.3.2 Backup Files
******* TODO 18.3.2.1 Single or Numbered Backups
******* TODO 18.3.2.2 Automatic Deletion of Backups
******* TODO 18.3.2.3 Copying vs. Renaming
****** TODO 18.3.3 Customizing Saving of Files
****** TODO 18.3.4 Protection against Simultaneous Editing
****** TODO 18.3.5 Shadowing Files
****** TODO 18.3.6 Updating Time Stamps Automatically
***** TODO 18.4 Reverting a Buffer
***** TODO [0/1] 18.5 Auto Revert: Keeping buffers automatically up-to-date
****** TODO [0/2] 18.5.1 Auto Reverting Non-File Buffers
******* TODO 18.5.1.1 Auto Reverting the Buffer Menu
******* TODO 18.5.1.2 Auto Reverting Dired buffers
***** TODO [0/3] 18.6 Auto-Saving: Protection Against Disasters
****** TODO 18.6.1 Auto-Save Files
****** TODO 18.6.2 Controlling Auto-Saving
****** TODO 18.6.3 Recovering Data from Auto-Saves
***** TODO 18.7 File Name Aliases
***** TODO 18.8 File Directories
***** TODO 18.9 Comparing Files
***** TODO 18.10 Diff Mode
***** TODO 18.11 Copying, Naming and Renaming Files
***** TODO 18.12 Miscellaneous File Operations
***** TODO 18.13 Accessing Compressed Files
***** TODO 18.14 File Archives
***** TODO 18.15 Remote Files
***** TODO 18.16 Quoted File Names
***** TODO 18.17 File Name Cache
***** TODO 18.18 Convenience Features for Finding Files
***** TODO 18.19 Viewing Image Files
***** TODO 18.20 Filesets
***** DONE Recent files

#+begin_src elisp
  ;; Recentf mode changes
  (defvar recentf-max-saved-items 1000)
  (defvar recentf-exclude '("/tmp/" "/ssh:"))
  (recentf-mode)
#+end_src

***** DONE Backup

Keep folders clean (create new directory when not yet existing)

#+begin_src elisp
  (make-directory (expand-file-name "backups/" org-directory) t)
  (setq backup-directory-alist `(("." . ,(expand-file-name "backups/" org-directory))))
#+end_src

***** DONE Save versions
:LOGBOOK:
- State "DONE"       from "TODO"       [2023-07-05 Wed 14:10]
:END:
I am not sure if I will end up using this or git, but here we are for now

#+begin_src elisp
(setq delete-old-versions -1)
(setq version-control t)
(setq vc-make-backup-files t)
(setq auto-save-file-name-transforms '((".*" "~/.emacs.d/auto-save-list/" t)))
#+end_src

***** DONE Auto saving

Away from my file tree

#+begin_src elisp
  (setq auto-save-file-name-transforms `((".*" ,temporary-file-directory t))
        create-lockfiles nil)
#+end_src

***** DONE Large file warning
:LOGBOOK:
- State "DONE"       from "TODO"       [2024-07-19 Fri 15:11]
:END:

#+begin_src elisp
  (setq large-file-warning-threshold (* 15 1024 1024))
#+end_src

***** DONE Move deleted files to trash
:LOGBOOK:
- State "DONE"       from "TODO"       [2024-07-19 Fri 15:15]
:END:

#+begin_src elisp
  (setq delete-by-moving-to-trash t)
#+end_src

***** DONE [[https://github.com/magit/magit][Magit]]
:PROPERTIES:
:CREATED:  [2023-01-29 Sun 10:12]
:CLOSED:   [2023-02-01 Wed 21:58]
:END:
:LOGBOOK:
- State "DONE"       from "TODO"       [2024-07-19 Fri 15:15]
:END:

#+begin_src elisp
  (use-package magit)
#+end_src

***** TODO [[https://github.com/DerBeutlin/filetags.el][Filetags: manage filetags in the filename]]
:PROPERTIES:
:TITLE:    Filetags: Emacs package to manage filetags in the filename
:URI:      https://github.com/DerBeutlin/filetags.el
:CREATED:  [2023-01-28 Sat 08:58]
:END:
:LOGBOOK:
- State "DONE"       from "TODO"       [2023-07-12 Wed 12:43]
:END:

#+begin_src elisp :tangle no
  (use-package filetags
    :config
    (setq filetags-enforce-controlled-vocabulary nil)
    (setq filetags-controlled-vocabulary '(("winter" "summer") ("emacs")))
    (setq filetags-load-controlled-vocabulary-from-file nil)
    )
#+end_src

***** TODO [[https://github.com/joostkremers/pandoc-mode][pandoc-mode]]
:PROPERTIES:
:TITLE:    GitHub - joostkremers/pandoc-mode: An Emacs minor mode for interacting with Pandoc.
:URI:      https://github.com/joostkremers/pandoc-mode
:CREATED:  [2023-01-29 Sun 10:20]
:END:
:LOGBOOK:
- State "DONE"       from "TODO"       [2023-08-18 Fri 13:04]
- State "DONE"       from "WAIT"       [2023-07-07 Fri 15:00]
- State "DONE"       from "TODO"       [2023-07-07 Fri 14:53]
:END:

#+begin_src elisp :tangle no
  (use-package pandoc-mode
    :after hydra
    :config
    (add-hook 'markdown-mode-hook 'pandoc-mode) ;; Pandoc minor mode in markdown
    (add-hook 'pandoc-mode-hook 'pandoc-load-default-settings) ;; if a settings file for this format exists
    )
#+end_src

****** DONE Install [[https://pandoc.org/index.html][Pandoc - index]]
CLOSED: [2023-01-31 Tue 05:11]
:PROPERTIES:
:CREATED:  [2023-01-29 Sun 10:15]
:CLOSED:   [2023-01-31 Tue 05:11]
:END:

**** TODO [0/7] 19 Using Multiple Buffers
***** TODO 19.1 Creating and Selecting Buffers
***** TODO 19.2 Listing Existing Buffers
***** TODO 19.3 Miscellaneous Buffer Operations
***** TODO 19.4 Killing Buffers
***** TODO 19.5 Operating on Several Buffers
***** TODO 19.6 Indirect Buffers
***** TODO [0/3] 19.7 Convenience Features and Customization of Buffer Handling
****** TODO 19.7.1 Making Buffer Names Unique
****** TODO 19.7.2 Fast minibuffer selection
****** TODO 19.7.3 Customizing Buffer Menus
**** TODO [3/9] Buffers
***** TODO [1/2] Icons
:LOGBOOK:
- State "DONE"       from "TODO"       [2024-07-09 Tue 17:08]
:END:

****** DONE [[https://github.com/domtronn/all-the-icons.el][all-the-icons.el]]
:LOGBOOK:
- State "DONE"       from "TODO"       [2024-07-19 Fri 14:01]
- State "DONE"       from "TODO"       [2024-06-27 Thu 11:02]
- State "DONE"       from "TODO"       [2023-08-28 Mon 18:55]
- State "DONE"       from "DONE"       [2023-08-18 Fri 12:31]
:END:

#+begin_src elisp
  (use-package all-the-icons
    :if (display-graphic-p)
    )
#+end_src

****** TODO [0/4] all-the-icons Mode Line
     :LOGBOOK:
     - State "DONE"       from "TODO"       [2024-07-09 Tue 17:07]
     - State "DONE"       from "TODO"       [2024-07-09 Tue 15:57]
     - State "DONE"       from "TODO"       [2023-08-28 Mon 18:54]
     :END:

#+begin_src elisp :tangle no
  (setq mode-line-format '("%e"
  			 (:eval
  			  (concat
  			   (custom-modeline-modified)
  			   (custom-modeline-region-info)
  			   (custom-modeline-flycheck-status)
  			   (custom-modeline-icon-vc)
  			   )
  			  )
  			 )
        )
#+end_src

******* TODO Modified or read only
:LOGBOOK:
- State "DONE"       from "TODO"       [2024-06-27 Thu 11:15]
:END:
#+begin_src elisp :tangle no
     (defun custom-modeline-modified ()
       (let* ((config-alist
               '(
                 ("*" all-the-icons-faicon-family all-the-icons-faicon "chain-broken" :height 1.2 :v-adjust -0.0)
                 ("-" all-the-icons-faicon-family all-the-icons-faicon "link" :height 1.2 :v-adjust -0.0)
                 ("%" all-the-icons-octicon-family all-the-icons-octicon "lock" :height 1.2 :v-adjust 0.1)
                 )
               )
              (result (cdr (assoc (format-mode-line "%*") config-alist)))
              )
         (propertize (apply (cadr result) (cddr result))
                     'face `(:family ,(funcall (car result)))
                     )
         )
       )
#+end_src

******* TODO Region marking
   :LOGBOOK:
   - State "DONE"       from "TODO"       [2024-06-27 Thu 11:15]
   - State "DONE"       from "TODO"       [2023-08-18 Fri 12:16]
   :END:

#+begin_src elisp :tangle no
  (defun custom-modeline-region-info ()
  (when mark-active
    (let ((words (count-lines (region-beginning) (region-end)))
          (chars (count-words (region-end) (region-beginning))))
      (concat
       (propertize (format "   %s" (all-the-icons-octicon "pencil") words chars)
                   'face `(:family ,(all-the-icons-octicon-family))
                   'display '(raise -0.0))
       (propertize (format " (%s, %s)" words chars)
                   'face `(:height 0.9))))))
#+end_src

******* TODO Version control icon
   :LOGBOOK:
   - State "DONE"       from "TODO"       [2024-06-27 Thu 11:15]
   - State "DONE"       from "TODO"       [2023-08-18 Fri 12:16]
   - State "DONE"       from "TODO"       [2023-07-07 Fri 12:17]
   :END:
#+begin_src elisp :tangle no
  (defun -custom-modeline-github-vc ()
    (let ((branch (mapconcat 'concat (cdr (split-string vc-mode "[:-]")) "-")))
      (concat
       (propertize (format " %s" (all-the-icons-alltheicon "git")) 'face `(:height 1.2) 'display '(raise -0.1))
       " · "
       (propertize (format "%s" (all-the-icons-octicon "git-branch"))
                   'face `(:height 1.3 :family ,(all-the-icons-octicon-family))
                   'display '(raise -0.1))
       (propertize (format " %s" branch) 'face `(:height 0.9)))))

  (defun -custom-modeline-svn-vc ()
    (let ((revision (cadr (split-string vc-mode "-"))))
      (concat
       (propertize (format " %s" (all-the-icons-faicon "cloud")) 'face `(:height 1.2) 'display '(raise -0.1))
       (propertize (format " · %s" revision) 'face `(:height 0.9)))))

  (defun custom-modeline-icon-vc ()
    (when vc-mode
      (cond
        ((string-match "Git[:-]" vc-mode) (-custom-modeline-github-vc))
        ((string-match "SVN-" vc-mode) (-custom-modeline-svn-vc))
        (t (format "%s" vc-mode)))))
#+end_src

******* TODO Flycheck checker information
   :LOGBOOK:
   - State "DONE"       from "TODO"       [2024-06-27 Thu 11:16]
   - State "DONE"       from "TODO"       [2023-08-18 Fri 11:49]
   :END:

#+begin_src elisp :tangle no
  (defun custom-modeline-flycheck-status ()
    (let* ((text (pcase flycheck-last-status-change
                 (`finished (if flycheck-current-errors
                                (let ((count (let-alist (flycheck-count-errors flycheck-current-errors)
                                               (+ (or .warning 0) (or .error 0)))))
                                  (format "✖ %s Issue%s" count (unless (eq 1 count) "s")))
                              "✔ No Issues"))
                 (`running     "⟲ Running")
                 (`no-checker  "⚠ No Checker")
                 (`not-checked "✖ Disabled")
                 (`errored     "⚠ Error")
                 (`interrupted "⛔ Interrupted")
                 (`suspicious  ""))))
      (propertize text
                  'help-echo "Show Flycheck Errors"
                  'mouse-face '(:box 1)
                  'local-map (make-mode-line-mouse-map
                              'mouse-1 (lambda () (interactive) (flycheck-list-errors))))))
#+end_src

***** TODO Scroll to the first and last line of the buffer

#+begin_src elisp :tangle no
 (setq scroll-error-top-bottom t)
#+end_src
  
***** DONE Narrow to region

#+begin_src elisp
  (put 'narrow-to-region 'disabled nil)
#+end_src

***** DONE Paragraph text wrapping

#+begin_src elisp
  (setq global-visual-line-mode t)
#+end_src

***** TODO Increase line spacing

#+begin_src elisp :tangle no
  (setq line-spacing 6)
#+end_src

***** TODO RTL Support
:LOGBOOK:
- State "DONE"       from "TODO"       [2023-07-05 Wed 12:19]
:END:

For a correct RTL display you can add the following snippet to your init file:

#+begin_src elisp :tangle no
    (defun set-bidi-env ()
      (interactive)
      (setq bidi-paragraph-direction 'nil)
      )

  (add-hook 'org-mode-hook 'set-bidi-env)
#+end_src

***** TODO File encoding system

#+begin_src elisp :tangle no
  (prefer-coding-system 'utf-8)
  (setq buffer-file-coding-system 'utf-8-auto-unix)
#+end_src

***** DONE Overwrite selected text

#+begin_src elisp
  (delete-selection-mode t)
#+end_src

***** TODO Expand region
:LOGBOOK:
- State "DONE"       from "NEXT"       [2023-08-03 Thu 13:11]
:END:

#+begin_src elisp :tangle no
  (use-package expand-region
    :bind ("C-=" . er/expand-region)
    )
#+end_src

**** TODO [0/8] 20 Multiple Windows
***** TODO 20.1 Concepts of Emacs Windows
***** TODO 20.2 Splitting Windows
***** TODO 20.3 Using Other Windows
***** TODO 20.4 Displaying in Another Window
***** TODO 20.5 Deleting and Resizing Windows
***** TODO [0/2] 20.6 Displaying a Buffer in a Window
****** TODO 20.6.1 How display-buffer works
****** TODO 20.6.2 Displaying non-editable buffers.
***** TODO 20.7 Convenience Features for Window Handling
***** TODO 20.8 Window Tab Line
**** TODO [3/22] 21 Frames and Graphical Displays
***** TODO 21.1 Mouse Commands for Editing
***** TODO 21.2 Mouse Commands for Words and Lines
***** TODO 21.3 Following References with the Mouse
***** TODO 21.4 Mouse Clicks for Menus
***** TODO 21.5 Mode Line Mouse Commands
***** TODO 21.6 Creating Frames
***** TODO 21.7 Frame Commands
***** TODO 21.8 Fonts
***** TODO 21.9 Speedbar Frames
***** TODO 21.10 Multiple Displays
***** TODO 21.11 Frame Parameters
***** DONE 21.12 Scroll Bars
:LOGBOOK:
- State "DONE"       from "TODO"       [2024-07-29 Mon 16:50]
:END:
#+begin_src elisp
  (when window-system
    (scroll-bar-mode 0)
    )
#+end_src
***** TODO 21.13 Window Dividers
***** TODO 21.14 Drag and Drop
***** DONE 21.15 Menu Bars
:LOGBOOK:
- State "DONE"       from "TODO"       [2024-07-29 Mon 16:49]
:END:
#+begin_src elisp
  (when window-system
    (menu-bar-mode 0)
    )
#+end_src
***** DONE 21.16 Tool Bars
:LOGBOOK:
- State "DONE"       from "TODO"       [2024-07-29 Mon 16:49]
:END:
#+begin_src elisp
  (when window-system
    (tool-bar-mode 0)
    )
#+end_src
***** TODO 21.17 Tab Bars
***** TODO 21.18 Using Dialog Boxes
***** TODO 21.19 Tooltips
***** TODO 21.20 Mouse Avoidance
***** TODO 21.21 Non-Window Terminals
***** TODO 21.22 Using a Mouse in Text Terminals
**** DONE [7/7] Frames
:LOGBOOK:

- State "DONE"       from "TODO"       [2024-07-20 Sat 11:07]
:END:
***** DONE Set the initial frame size and position
 :LOGBOOK:
 - State "DONE"       from "TODO"       [2024-07-20 Sat 11:03]
 - State "DONE"       from "TODO"       [2024-07-08 Mon 22:11]
 :END:

 #+begin_src elisp
   ;; initial frame
   (setq initial-frame-alist
         '((width . 192) ; characters in a line
           (height . 37) ; number of lines
           (top . 1) ; top position
           (left . 1) ; left position
           )
         )

   ;; sebsequent frame
   (setq default-frame-alist
         '((width . 192) ; characters in a line
           (height . 37) ; number of lines
           )
         )
 #+end_src

***** DONE Set frame margins to zero, window margins to zero

 #+begin_src elisp
   (modify-all-frames-parameters '((internal-border-width . 0)))
 #+end_src

***** DONE Initial screen
:LOGBOOK:
- State "DONE"       from "TODO"       [2024-07-19 Fri 13:59]
:END:

#+begin_src elisp
  (setq inhibit-splash-screen t)
  (setq inhibit-startup-message t)
  (setq initial-scratch-message "")
  (setq initial-major-mode 'org-mode)
#+end_src

***** DONE Startup echo message

#+begin_src elisp
  (defun display-startup-echo-area-message ()
    "Display a welcome message."
    (message "Ladies and gentlemen, we are floating in space!")
    )
#+end_src

***** DONE [[https://protesilaos.com/emacs/ef-themes][Theme]]
:LOGBOOK:
- State "DONE"       from "TODO"       [2024-07-16 Tue 19:50]
- State "DONE"       from "TODO"       [2024-07-10 Wed 17:06]
:END:

#+begin_src elisp
   ;; Make customisations that affect Emacs faces BEFORE loading a theme
   ;; (any change needs a theme re-load to take effect).

;;  (require 'ef-themes)
  (use-package ef-themes
    :config
    ;; If you like two specific themes and want to switch between them, you
    ;; can specify them in `ef-themes-to-toggle' and then invoke the command
    ;; `ef-themes-toggle'.  All the themes are included in the variable
    ;; `ef-themes-collection'.
    (defvar ef-themes-to-toggle '(ef-summer ef-winter))

    (defvar ef-themes-headings ; read the manual's entry or the doc string
      '((0 variable-pitch light 1.9)
        (1 variable-pitch light 1.8)
        (2 variable-pitch regular 1.7)
        (3 variable-pitch regular 1.6)
        (4 variable-pitch regular 1.5)
        (5 variable-pitch 1.4) ; absence of weight means `bold'
        (6 variable-pitch 1.3)
        (7 variable-pitch 1.2)
        (t variable-pitch 1.1)))

    ;; They are nil by default...
    (defvar ef-themes-mixed-fonts t)
    (defvar ef-themes-variable-pitch-ui t)

    ;; Disable all other themes to avoid awkward blending:
    (mapc #'disable-theme custom-enabled-themes)

    ;; Load the theme of choice:
    (load-theme 'ef-winter :no-confirm)
     
    ;; OR use this to load the theme which also calls `ef-themes-post-load-hook':
    (ef-themes-select 'ef-winter)

    ;; The themes we provide are recorded in the `ef-themes-dark-themes',
    ;; `ef-themes-light-themes'.

    ;; We also provide these commands, but do not assign them to any key:
    ;;
    ;; - `ef-themes-toggle'
    ;; - `ef-themes-select'
    ;; - `ef-themes-select-dark'
    ;; - `ef-themes-select-light'
    ;; - `ef-themes-load-random'
    ;; - `ef-themes-preview-colors'
    ;; - `ef-themes-preview-colors-current'
    )
#+end_src

***** DONE Set the cursor shape and blinking
:LOGBOOK:
- State "DONE"       from "TODO"       [2024-07-20 Sat 11:05]
:END:

#+begin_src elisp
  (setq-default cursor-type '(box . 1)) ; Bar cursor
  (blink-cursor-mode -1) ; Don't blink the cursor
#+end_src

**** TODO [9/10] Windows
:LOGBOOK:
- State "DONE"       from "DONE"       [2024-07-16 Tue 20:04]
:END:

***** DONE Save windows arrangement
#+begin_src elisp
  (when (fboundp 'winner-mode)
    (winner-mode t)
    )
#+end_src
  
***** DONE Switch to other-window
:LOGBOOK:
- State "DONE"       from "TODO"       [2024-07-16 Tue 20:04]
:END:

#+begin_src elisp
  (use-package ace-window
    :config
    (global-set-key (kbd "M-o") 'ace-window)
    (defvar aw-dispatch-always nil) ; works for less than three buffers
    )
#+end_src

***** DONE Neotree
 :LOGBOOK:
 - State "DONE"       from "TODO"       [2024-07-19 Fri 15:22]
 - State "DONE"       from "TODO"       [2023-07-05 Wed 16:48]
 :END:

 #+begin_src elisp
   (use-package neotree
     :init (defvar neo-smart-open t)
     :config (defvar neo-theme (if (display-graphic-p) 'icons 'arrow))
   )
 #+end_src

***** DONE Tab Line
:LOGBOOK:
- State "DONE"       from "TODO"       [2024-07-16 Tue 19:51]
:END:
    
#+begin_src elisp
  (global-tab-line-mode)
#+end_src

***** DONE [3/3] Mode Line
:LOGBOOK:
- State "DONE"       from "TODO"       [2024-07-20 Sat 11:10]
- State "DONE"       from "DONE"       [2024-07-09 Tue 17:08]
:END:

****** DONE Basic settings

#+begin_src elisp
  (use-package mood-line
  ;; Enable mood-line
  :config
  (mood-line-mode)

  ;; Use pretty Fira Code-compatible glyphs
  (defvar mood-line-glyph-alist mood-line-glyphs-fira-code)
  )
#+end_src

****** DONE [3/3] Format
:LOGBOOK:
- State "DONE"       from "TODO"       [2024-07-19 Fri 15:26]
:END:

******** DONE Default format

#+begin_src elisp
  ;; Default format:
  ;;   * init.el  4:32 Top                                         ELisp  ! Issues: 2
  (defvar mood-line-format mood-line-format-default)
#+end_src

******** CNCL Extended format

#+begin_src elisp :tangle no
  ;; Extended format:
  ;;   * init.el  4:32:52 Top                    SPCx2  LF  UTF-8  ELisp  ! Issues: 2
  (defvar mood-line-format mood-line-format-default-extended)
#+end_src

******** CNCL Custom format

#+begin_src elisp :tangle no
  ;; Custom format:
  ;;   * init.el : ELisp                                     Top 4:32  |  ! Issues: 2
  (setq mood-line-format
        (mood-line-defformat
         :left
         (((mood-line-segment-buffer-status) . " ")
          ((mood-line-segment-buffer-name)   . " : ")
          (mood-line-segment-major-mode))
         :right
         (((mood-line-segment-scroll)             . " ")
          ((mood-line-segment-cursor-position)    . "  ")
          ((when (mood-line-segment-checker) "|") . "  ")
          ((mood-line-segment-checker)            . "  "))))
#+end_src

****** DONE [3/3] Glyphs
******** CNCL Default glyphs

#+begin_src elisp :tangle no
  ;; The default set of glyphs:
  ;;   * myModifiedFile.js  Replace*3                 + main  JavaScript  ! Issues: 2
  (defvar mood-line-glyph-alist mood-line-glyphs-ascii)
#+end_src

******** CNCL Fira Code-compatible Unicode glyphs

#+begin_src elisp :tangle no
  ;; A set of Fira Code-compatible Unicode glyphs:
  ;;   ● myModifiedFile.js  Replace×3                 + main  JavaScript  → Issues: 2
  (setq mood-line-glyph-alist mood-line-glyphs-fira-code)
#+end_src

********  DONE Unicode glyphs

#+begin_src elisp
  ;; A set of Unicode glyphs:
  ;;   ● myModifiedFile.js  Replace✕3                 🞤 main  JavaScript  ⚑ Issues: 2
  (defvar mood-line-glyph-alist mood-line-glyphs-unicode)
#+end_src

***** CNCL Add clock
:LOGBOOK:
- State "DONE"       from "TODO"       [2023-07-05 Wed 16:48]
:END:
Modify this later to show clock only in full-screen mode

#+begin_src elisp :tangle no
(display-time-mode nil)
#+end_src

***** DONE [[https://github.com/emacsmirror/diminish][Diminish]] minor modes from the mode line
:LOGBOOK:
- State "DONE"       from "NEXT"       [2023-08-03 Thu 13:05]
:END:

#+begin_src elisp
   (use-package diminish
     :demand t
     :diminish (visual-line-mode . "ω")
     :diminish abbrev-mode
     :diminish auto-fill-function
     )
#+end_src

***** DONE [[https://github.com/justbur/emacs-which-key][Which-key]]

Figure out the next keystroke. which-key package opens a small buffer at the bottom with suggestions for next keystroke and possible commands that are available

#+begin_src elisp
  (use-package which-key
    :config
    (defvar which-key-sort-order 'which-key-key-order-alpha)
    (defvar which-key-idle-delay 0.05)
    (which-key-mode)
    (which-key-setup-minibuffer)
    (which-key-setup-side-window-right)
    )
#+end_src

**** TODO [0/19] 22 International Character Set Support
***** TODO 22.1 Introduction to International Character Sets
***** TODO 22.2 Language Environments
***** TODO 22.3 Input Methods
***** TODO 22.4 Selecting an Input Method
***** TODO 22.5 Coding Systems
***** TODO 22.6 Recognizing Coding Systems
***** TODO 22.7 Specifying a File’s Coding System
***** TODO 22.8 Choosing Coding Systems for Output
***** TODO 22.9 Specifying a Coding System for File Text
***** TODO 22.10 Coding Systems for Interprocess Communication
***** TODO 22.11 Coding Systems for File Names
***** TODO 22.12 Coding Systems for Terminal I/O
***** TODO 22.13 Fontsets
***** TODO 22.14 Defining Fontsets
***** TODO 22.15 Modifying Fontsets
***** TODO 22.16 Undisplayable Characters
***** TODO 22.17 Unibyte Editing Mode
***** TODO 22.18 Charsets
***** TODO 22.19 Bidirectional Editing
**** TODO [0/2] International
***** TODO [0/1] Fonts
:LOGBOOK:
- State "DONE"       from              [2023-08-22 Tue 11:10]
:END:

#+begin_src elisp
  (set-face-attribute 'default nil :font "Arial") ;; default font
  (set-fontset-font t nil "sans-serif" nil 'append) ;; fallback font
  (set-fontset-font t 'arabic "Amiri") ;; default Arabic font
  (set-face-attribute 'fixed-pitch nil :family "Thabit")
  (set-fontset-font t 'arabic "Simplified Arabic" nil 'append) ;; default Arabic fallback
  (set-fontset-font t 'arabic (font-spec :script 'arabic) nil 'append) ;; if font not available, don't display boxes
#+end_src

***** TODO [[https://github.com/rolandwalker/unicode-fonts][Unicode Fonts]]

[[https://www.emacswiki.org/emacs/UnicodeFonts][EmacsWiki]]: If you are using a language written in Chinese or Arabic script, try customizing ‘unicode-fonts-skip-font-groups’ to control which script you see, and send a friendly bug report.

#+begin_src elisp :tangle no
  (use-package unicode-fonts
    :config
    (defvar unicode-fonts-block-font-mapping
      '(("Emoticons" ("Apple Color Emoji" "Symbola" "Quivira"))))
    (defvar unicode-fonts-fontset-names '("fontset-default"))
    (defvar unicode-skip-font-groups '(""))
    (unicode-fonts-setup)
    )
#+end_src

**** TODO [1/4] 23 Major and Minor Modes
***** TODO 23.1 Major Modes
***** TODO 23.2 Minor Modes
***** TODO 23.3 Choosing File Modes
***** CNCL Discover major mode
:LOGBOOK:
- State "CNCL"       from "DONE"       [2024-07-10 Wed 11:30] \\
  Not needed
- State "DONE"       from "TODO"       [2023-07-05 Wed 16:48]
:END:

#+begin_src elisp :tangle no
  (use-package discover-my-major
    :bind (("C-h C-m" . discover-my-major)
           ("C-h M-m" . discover-my-mode)
           )
    )
#+end_src

**** TODO [0/4] 24 Indentation
***** TODO 24.1 Indentation Commands
***** TODO 24.2 Tab Stops
***** TODO 24.3 Tabs vs. Spaces
***** TODO 24.4 Convenience Features for Indentation
**** TODO [0/16] 25 Commands for Human Languages
***** TODO 25.1 Words
***** TODO 25.2 Sentences
***** TODO 25.3 Paragraphs
***** TODO 25.4 Pages
***** TODO 25.5 Quotation Marks
***** TODO [0/4] 25.6 Filling Text
****** TODO 25.6.1 Auto Fill Mode
****** TODO 25.6.2 Explicit Fill Commands
****** TODO 25.6.3 The Fill Prefix
****** TODO 25.6.4 Adaptive Filling
***** TODO 25.7 Case Conversion Commands
***** TODO 25.8 Text Mode
***** TODO [0/5] 25.9 Outline Mode
****** TODO 25.9.1 Format of Outlines
****** TODO 25.9.2 Outline Motion Commands
****** TODO 25.9.3 Outline Visibility Commands
****** TODO 25.9.4 Viewing One Outline in Multiple Views
****** TODO 25.9.5 Folding Editing
***** TODO [0/2] 25.10 Org Mode
****** TODO 25.10.1 Org as an organizer
****** TODO 25.10.2 Org as an authoring system
***** TODO [0/4] 25.11 TeX Mode
****** TODO 25.11.1 TeX Editing Commands
****** TODO 25.11.2 LaTeX Editing Commands
****** TODO 25.11.3 TeX Printing Commands
****** TODO 25.11.4 TeX Mode Miscellany
***** TODO 25.12 SGML and HTML Modes
***** TODO 25.13 Nroff Mode
***** TODO [0/7] 25.14 Enriched Text
****** TODO 25.14.1 Enriched Mode
****** TODO 25.14.2 Hard and Soft Newlines
****** TODO 25.14.3 Editing Format Information
****** TODO 25.14.4 Faces in Enriched Text
****** TODO 25.14.5 Indentation in Enriched Text
****** TODO 25.14.6 Justification in Enriched Text
****** TODO 25.14.7 Setting Other Text Properties
***** TODO [0/8] 25.15 Editing Text-based Tables
****** TODO 25.15.1 What is a Text-based Table?
****** TODO 25.15.2 Creating a Table
****** TODO 25.15.3 Table Recognition
****** TODO 25.15.4 Commands for Table Cells
****** TODO 25.15.5 Cell Justification
****** TODO 25.15.6 Table Rows and Columns
****** TODO 25.15.7 Converting Between Plain Text and Tables
****** TODO 25.15.8 Table Miscellany
***** TODO 25.16 Two-Column Editing
**** TODO [0/14] 26 Editing Programs
***** TODO 26.1 Major Modes for Programming Languages
***** TODO [0/4] 26.2 Top-Level Definitions, or Defuns
****** TODO 26.2.1 Left Margin Convention
****** TODO 26.2.2 Moving by Defuns
****** TODO 26.2.3 Imenu
****** TODO 26.2.4 Which Function Mode
***** TODO [0/5] 26.3 Indentation for Programs
****** TODO 26.3.1 Basic Program Indentation Commands
****** TODO 26.3.2 Indenting Several Lines
****** TODO 26.3.3 Customizing Lisp Indentation
****** TODO 26.3.4 Commands for C Indentation
****** TODO 26.3.5 Customizing C Indentation
***** TODO [0/3] 26.4 Commands for Editing with Parentheses
****** TODO 26.4.1 Expressions with Balanced Parentheses
****** TODO 26.4.2 Moving in the Parenthesis Structure
****** TODO 26.4.3 Matching Parentheses
***** TODO [0/3] 26.5 Manipulating Comments
****** TODO 26.5.1 Comment Commands
****** TODO 26.5.2 Multiple Lines of Comments
****** TODO 26.5.3 Options Controlling Comments
***** TODO [0/3] 26.6 Documentation Lookup
****** TODO 26.6.1 Info Documentation Lookup
****** TODO 26.6.2 Man Page Lookup
****** TODO 26.6.3 Emacs Lisp Documentation Lookup
***** TODO 26.7 Hideshow minor mode
***** TODO 26.8 Completion for Symbol Names
***** TODO 26.9 MixedCase Words
***** TODO 26.10 Semantic
***** TODO 26.11 Other Features Useful for Editing Programs
***** TODO [0/4] 26.12 C and Related Modes
****** TODO 26.12.1 C Mode Motion Commands
****** TODO 26.12.2 Electric C Characters
****** TODO 26.12.3 Hungry Delete Feature in C
****** TODO 26.12.4 Other Commands for C Mode
***** TODO 26.13 Asm Mode
***** TODO [0/6] 26.14 Fortran Mode
****** TODO 26.14.1 Motion Commands
****** TODO [0/5] 26.14.2 Fortran Indentation
******* TODO 26.14.2.1 Fortran Indentation and Filling Commands
******* TODO 26.14.2.2 Continuation Lines
******* TODO 26.14.2.3 Line Numbers
******* TODO 26.14.2.4 Syntactic Conventions
******* TODO 26.14.2.5 Variables for Fortran Indentation
****** TODO 26.14.3 Fortran Comments
****** TODO 26.14.4 Auto Fill in Fortran Mode
****** TODO 26.14.5 Checking Columns in Fortran
****** TODO 26.14.6 Fortran Keyword Abbrevs
**** TODO [0/11] 27 Compiling and Testing Programs
***** TODO 27.1 Running Compilations under Emacs
***** TODO 27.2 Compilation Mode
***** TODO 27.3 Subshells for Compilation
***** TODO 27.4 Searching with Grep under Emacs
***** TODO 27.5 Finding Syntax Errors On The Fly
***** TODO [0/5] 27.6 Running Debuggers Under Emacs
****** TODO 27.6.1 Starting GUD
****** TODO 27.6.2 Debugger Operation
****** TODO 27.6.3 Commands of GUD
****** TODO 27.6.4 GUD Customization
****** TODO [0/8] 27.6.5 GDB Graphical Interface
******* TODO 27.6.5.1 GDB User Interface Layout
******* TODO 27.6.5.2 Source Buffers
******* TODO 27.6.5.3 Breakpoints Buffer
******* TODO 27.6.5.4 Threads Buffer
******* TODO 27.6.5.5 Stack Buffer
******* TODO 27.6.5.6 Other GDB Buffers
******* TODO 27.6.5.7 Watch Expressions
******* TODO 27.6.5.8 Multithreaded Debugging
***** TODO 27.7 Executing Lisp Expressions
***** TODO 27.8 Libraries of Lisp Code for Emacs
***** TODO 27.9 Evaluating Emacs Lisp Expressions
***** TODO 27.10 Lisp Interaction Buffers
***** TODO 27.11 Running an External Lisp
**** TODO [0/7] 28 Maintaining Large Programs
***** TODO [0/13] 28.1 Version Control
****** TODO [0/7] 28.1.1 Introduction to Version Control
******* TODO 28.1.1.1 Understanding the Problems it Addresses
******* TODO 28.1.1.2 Supported Version Control Systems
******* TODO 28.1.1.3 Concepts of Version Control
******* TODO 28.1.1.4 Merge-based vs Lock-based Version Control
******* TODO 28.1.1.5 Changeset-based vs File-based Version Control
******* TODO 28.1.1.6 Decentralized vs Centralized Repositories
******* TODO 28.1.1.7 Types of Log File
****** TODO 28.1.2 Version Control and the Mode Line
****** TODO [0/3] 28.1.3 Basic Editing under Version Control
******* TODO 28.1.3.1 Basic Version Control with Merging
******* TODO 28.1.3.2 Basic Version Control with Locking
******* TODO 28.1.3.3 Advanced Control in C-x v v
****** TODO 28.1.4 Features of the Log Entry Buffer
****** TODO 28.1.5 Registering a File for Version Control
****** TODO 28.1.6 Examining And Comparing Old Revisions
****** TODO 28.1.7 VC Change Log
****** TODO 28.1.8 Undoing Version Control Actions
****** TODO 28.1.9 Ignore Version Control Files
****** TODO [0/2] 28.1.10 VC Directory Mode
******* TODO 28.1.10.1 The VC Directory Buffer
******* TODO 28.1.10.2 VC Directory Commands
****** TODO [0/4] 28.1.11 Version Control Branches
******* TODO 28.1.11.1 Switching between Branches
******* TODO 28.1.11.2 Pulling/Pushing Changes into/from a Branch
******* TODO 28.1.11.3 Merging Branches
******* TODO 28.1.11.4 Creating New Branches
****** TODO [0/4] 28.1.12 Miscellaneous Commands and Features of VC
******* TODO 28.1.12.1 Change Logs and VC
******* TODO 28.1.12.2 Deleting and Renaming Version-Controlled Files
******* TODO 28.1.12.3 Revision Tags
******* TODO 28.1.12.4 Inserting Version Control Headers
****** TODO [0/3] 28.1.13 Customizing VC
******* TODO 28.1.13.1 General Options
******* TODO 28.1.13.2 Options for RCS and SCCS
******* TODO 28.1.13.3 Options specific for CVS
***** TODO [0/4] 28.2 Working with Projects
****** TODO 28.2.1 Project Commands That Operate on Files
****** TODO 28.2.2 Project Commands That Operate on Buffers
****** TODO 28.2.3 Switching Projects
****** TODO 28.2.4 Managing the Project List File
***** TODO [0/2] 28.3 Change Logs
****** TODO 28.3.1 Change Log Commands
****** TODO 28.3.2 Format of ChangeLog
***** TODO [0/3] 28.4 Find Identifier References
****** TODO [0/4] 28.4.1 Find Identifiers
******* TODO 28.4.1.1 Looking Up Identifiers
******* TODO 28.4.1.2 Commands Available in the *xref* Buffer
******* TODO 28.4.1.3 Searching and Replacing with Identifiers
******* TODO 28.4.1.4 Identifier Inquiries
****** TODO [0/3] 28.4.2 Tags Tables
******* TODO 28.4.2.1 Source File Tag Syntax
******* TODO 28.4.2.2 Creating Tags Tables
******* TODO 28.4.2.3 Etags Regexps
****** TODO 28.4.3 Selecting a Tags Table
***** TODO 28.5 Emacs Development Environment
***** TODO [0/7] 28.6 Merging Files with Emerge
****** TODO 28.6.1 Overview of Emerge
****** TODO 28.6.2 Submodes of Emerge
****** TODO 28.6.3 State of a Difference
****** TODO 28.6.4 Merge Commands
****** TODO 28.6.5 Exiting Emerge
****** TODO 28.6.6 Combining the Two Versions
****** TODO 28.6.7 Fine Points of Emerge
***** TODO 28.7 Bug Reference
**** TODO [0/8] 29 Abbrevs
***** TODO 29.1 Abbrev Concepts
***** TODO 29.2 Defining Abbrevs
***** TODO 29.3 Controlling Abbrev Expansion
***** TODO 29.4 Abbrevs Suggestions
***** TODO 29.5 Examining and Editing Abbrevs
***** TODO 29.6 Saving Abbrevs
***** TODO 29.7 Dynamic Abbrev Expansion
***** TODO 29.8 Customizing Dynamic Abbreviation
**** TODO [0/22] 30 Dired, the Directory Editor
***** TODO 30.1 Entering Dired
***** TODO 30.2 Navigation in the Dired Buffer
***** TODO 30.3 Deleting Files with Dired
***** TODO 30.4 Flagging Many Files at Once
***** TODO 30.5 Visiting Files in Dired
***** TODO 30.6 Dired Marks vs. Flags
***** TODO 30.7 Operating on Files
***** TODO 30.8 Shell Commands in Dired
***** TODO 30.9 Transforming File Names in Dired
***** TODO 30.10 File Comparison with Dired
***** TODO 30.11 Subdirectories in Dired
***** TODO 30.12 Subdirectory Switches in Dired
***** TODO 30.13 Moving Over Subdirectories
***** TODO 30.14 Hiding Subdirectories
***** TODO 30.15 Updating the Dired Buffer
***** TODO 30.16 Dired and find
***** TODO 30.17 Editing the Dired Buffer
***** TODO 30.18 Viewing Image Thumbnails in Dired
***** TODO 30.19 Other Dired Features
***** TODO Basic settings

#+begin_src elisp :tangle no
  (use-package dired
    :init
    (setq dired-dwim-target t)
    (setq dired-recursive-copies 'top)
    (setq dired-recursive-deletes 'top)
    (setq dired-listing-switches "-alh")
    (setq dired-listing-switches "-agho --group-directories-first") ; Sort Dired buffers
    (setq dired-dwim-target  t) ; Copy and move files netween dired buffers
    :config
    (add-hook 'dired-mode-hook 'dired-hide-details-mode)
    (add-hook 'dired-mode-hook 'all-the-icons-dired-mode)
    :bind (:map dired-mode-map
                ("C-c C-e" . wdired-change-to-wdired-mode))
    )
#+end_src

***** TODO Images in dired

#+begin_src elisp :tangle no
  ;; Image-dired Keyboard shortcuts
  (with-eval-after-load 'dired
    (define-key dired-mode-map (kbd "C-t C-d") 'image-dired)
    (define-key dired-mode-map (kbd "C-<return>") 'image-dired-dired-display-external)
    )

  (setq image-dired-external-viewer "/usr/bin/gimp") ; Define external image viewer/edito
  (put 'dired-find-alternate-file 'disabled nil) ; Open dired in same buffer
#+end_src

***** TODO Icons in dired

#+begin_src elisp :tangle no
  (use-package all-the-icons-dired
    :after dired all-the-icons
    :if (display-graphic-p)
    )
#+end_src

***** TODO [[https://github.com/DerBeutlin/date2name.el][Date2name: add ISO timestamps to files in dired]]
:PROPERTIES:
:TITLE:    GitHub - DerBeutlin/date2name.el: Emacs package to add ISO timestamps to files in dired
:URI:      https://github.com/DerBeutlin/date2name.el
:CREATED:  [2023-01-28 Sat 06:20]
:END:
:LOGBOOK:
- State "DONE"       from "TODO"       [2023-07-12 Wed 12:44]
:END:

#+begin_src elisp :tangle no
  (use-package date2name)
#+end_src

**** TODO [0/10] 31 The Calendar and the Diary
***** TODO [0/3] 31.1 Movement in the Calendar
****** TODO 31.1.1 Motion by Standard Lengths of Time
****** TODO 31.1.2 Beginning or End of Week, Month or Year
****** TODO 31.1.3 Specified Dates
***** TODO 31.2 Scrolling in the Calendar
***** TODO 31.3 Counting Days
***** TODO 31.4 Miscellaneous Calendar Commands
***** TODO 31.5 Writing Calendar Files
***** TODO 31.6 Holidays
***** TODO 31.7 Times of Sunrise and Sunset
***** TODO 31.8 Phases of the Moon
***** TODO [0/3] 31.9 Conversion To and From Other Calendars
****** TODO 31.9.1 Supported Calendar Systems
****** TODO 31.9.2 Converting To Other Calendars
****** TODO 31.9.3 Converting From Other Calendars
***** TODO [0/10] 31.10 The Diary
****** TODO 31.10.1 The Diary File
****** TODO 31.10.2 Displaying the Diary
****** TODO 31.10.3 Date Formats
****** TODO 31.10.4 Commands to Add to the Diary
****** TODO 31.10.5 Special Diary Entries
****** TODO 31.10.6 Appointments
****** TODO 31.10.7 Importing and Exporting Diary Entries
****** TODO 31.11 Daylight Saving Time
****** TODO 31.12 Summing Time Intervals
****** TODO [0/10] 31.13 More advanced features of the Calendar and Diary
******* TODO 31.13.1 Customizing the Calendar
******* TODO 31.13.2 Customizing the Holidays
******* TODO 31.13.3 Converting from the Mayan Calendar
******* TODO 31.13.4 Date Display Format
******* TODO 31.13.5 Time Display Format
******* TODO 31.13.6 Customizing the Diary
******* TODO 31.13.7 Diary Entries Using non-Gregorian Calendars
******* TODO 31.13.8 Diary Display
******* TODO 31.13.9 Fancy Diary Display
******* TODO 31.13.10 Sexp Entries and the Fancy Diary Display
**** TODO [0/7] 32 Sending Mail
***** TODO 32.1 The Format of the Mail Buffer
***** TODO 32.2 Mail Header Fields
***** TODO 32.3 Mail Aliases
***** TODO [0/4] 32.4 Mail Commands
****** TODO 32.4.1 Mail Sending
****** TODO 32.4.2 Mail Header Editing
****** TODO 32.4.3 Citing Mail
****** TODO 32.4.4 Mail Miscellany
***** TODO 32.5 Mail Signature
***** TODO 32.6 Mail Amusements
***** TODO 32.7 Mail-Composition Methods
**** TODO [0/20] 33 Reading Mail with Rmail
***** TODO 33.1 Basic Concepts of Rmail
***** TODO 33.2 Scrolling Within a Message
***** TODO 33.3 Moving Among Messages
***** TODO 33.4 Deleting Messages
***** TODO 33.5 Rmail Files and Inboxes
***** TODO 33.6 Multiple Rmail Files
***** TODO 33.7 Copying Messages Out to Files
***** TODO 33.8 Labels
***** TODO 33.9 Rmail Attributes
***** TODO 33.10 Sending Replies
***** TODO [0/2] 33.11 Summaries
****** TODO 33.11.1 Making Summaries
****** TODO 33.11.2 Editing in Summaries
***** TODO 33.12 Sorting the Rmail File
***** TODO 33.13 Display of Messages
***** TODO 33.14 Rmail and Coding Systems
***** TODO 33.15 Editing Within a Message
***** TODO 33.16 Digest Messages
***** TODO 33.17 Reading Rot13 Messages
***** TODO 33.18 movemail program
***** TODO 33.19 Retrieving Mail from Remote Mailboxes
***** TODO 33.20 Retrieving Mail from Local Mailboxes in Various Formats
**** TODO [0/4] 34 Email and Usenet News with Gnus
***** TODO 34.1 Gnus Buffers
***** TODO 34.2 When Gnus Starts Up
***** TODO 34.3 Using the Gnus Group Buffer
***** TODO 34.4 Using the Gnus Summary Buffer
**** TODO 35 Host Security
**** TODO 36 Network Security
**** TODO [0/4] 37 Document Viewing
***** TODO 37.1 DocView Navigation
***** TODO 37.2 DocView Searching
***** TODO 37.3 DocView Slicing
#+begin_src elisp
  (setq doc-view-continuous t)
#+end_src
***** TODO 37.4 DocView Conversion
**** TODO [0/11] 38 Running Shell Commands from Emacs
***** TODO 38.1 Single Shell Commands
***** TODO 38.2 Interactive Subshell
***** TODO 38.3 Shell Mode
***** TODO 38.4 Shell Prompts
***** TODO [0/3] 38.5 Shell Command History
****** TODO 38.5.1 Shell History Ring
****** TODO 38.5.2 Shell History Copying
****** TODO 38.5.3 Shell History References
***** TODO 38.6 Directory Tracking
***** TODO 38.7 Shell Mode Options
***** TODO 38.8 Emacs Terminal Emulator
***** TODO 38.9 Term Mode
***** TODO 38.10 Remote Host Shell
***** TODO 38.11 Serial Terminal
**** TODO [0/3] 39 Using Emacs as a Server
***** TODO 39.1 TCP Emacs server
***** TODO 39.2 Invoking emacsclient
***** TODO 39.3 emacsclient Options
**** TODO [0/4] 40 Printing Hard Copies
***** TODO 40.1 PostScript Hardcopy
***** TODO 40.2 Variables for PostScript Hardcopy
***** TODO 40.3 Printing Package
**** TODO 41 Sorting Text
**** TODO [0/4] 42 Editing Pictures
***** TODO 42.1 Basic Editing in Picture Mode
***** TODO 42.2 Controlling Motion after Insert
***** TODO 42.3 Picture Mode Tabs
***** TODO 42.4 Picture Mode Rectangle Commands
**** TODO 43 Editing Binary Files
**** TODO 44 Saving Emacs Sessions
**** TODO 45 Recursive Editing Levels
**** TODO [0/5] 46 Hyperlinking and Web Navigation Features
***** TODO 46.1 Web Browsing with EWW
***** TODO 46.2 Embedded WebKit Widgets
***** TODO 46.3 Following URLs
***** TODO 46.4 Activating URLs
***** TODO 46.5 Finding Files and URLs at Point
**** TODO 47 Games and Other Amusements
**** TODO [0/4] 48 Emacs Lisp Packages
***** TODO 48.1 The Package Menu Buffer
***** TODO 48.2 Package Statuses
***** TODO 48.3 Package Installation
***** TODO 48.4 Package Files and Directory Layout
**** TODO [0/5] 49 Customization
***** TODO [0/8] 49.1 Easy Customization Interface
****** TODO 49.1.1 Customization Groups
****** TODO 49.1.2 Browsing and Searching for Settings
****** TODO 49.1.3 Changing a Variable
****** TODO 49.1.4 Saving Customizations
****** TODO 49.1.5 Customizing Faces
****** TODO 49.1.6 Customizing Specific Items
****** TODO 49.1.7 Custom Themes
****** TODO 49.1.8 Creating Custom Themes
***** TODO [0/8] 49.2 Variables
****** TODO 49.2.1 Examining and Setting Variables
****** TODO 49.2.2 Hooks
****** TODO 49.2.3 Local Variables
****** TODO 49.2.4 Local Variables in Files
****** TODO 49.2.4.1 Specifying File Variables
****** TODO 49.2.4.2 Safety of File Variables
****** TODO 49.2.5 Per-Directory Local Variables
****** TODO 49.2.6 Per-Connection Local Variables
***** TODO [0/11] 49.3 Customizing Key Bindings
****** TODO 49.3.1 Keymaps
****** TODO 49.3.2 Prefix Keymaps
****** TODO 49.3.3 Local Keymaps
****** TODO 49.3.4 Minibuffer Keymaps
****** TODO 49.3.5 Changing Key Bindings Interactively
****** TODO 49.3.6 Rebinding Keys in Your Init File
****** TODO 49.3.7 Modifier Keys
****** TODO 49.3.8 Rebinding Function Keys
****** TODO 49.3.9 Named ASCII Control Characters
****** TODO 49.3.10 Rebinding Mouse Buttons
****** TODO 49.3.11 Disabling Commands
***** TODO [0/6] 49.4 The Emacs Initialization File
****** TODO 49.4.1 Init File Syntax
****** TODO 49.4.2 Init File Examples
****** TODO 49.4.3 Terminal-specific Initialization
****** TODO 49.4.4 How Emacs Finds Your Init File
****** TODO 49.4.5 Non-ASCII Characters in Init Files
****** TODO 49.4.6 The Early Init File
***** TODO 49.5 Keeping Persistent Authentication Information
**** TODO 50 Quitting and Aborting
**** TODO [0/9] 51 Dealing with Emacs Trouble
***** TODO 51.1 If DEL Fails to Delete
***** TODO 51.2 Recursive Editing Levels
***** TODO 51.3 Garbage on the Screen
***** TODO 51.4 Garbage in the Text
***** TODO 51.5 Running out of Memory
***** TODO 51.6 When Emacs Crashes
***** TODO 51.7 Recovery After a Crash
***** TODO 51.8 Emergency Escape
***** TODO 51.9 Long Lines
**** TODO [0/5] 52 Reporting Bugs
***** TODO 52.1 Reading Existing Bug Reports and Known Problems
***** TODO 52.2 When Is There a Bug
***** TODO 52.3 Understanding Bug Reporting
***** TODO 52.4 Checklist for Bug Reports
***** TODO 52.5 Sending Patches for GNU Emacs
**** TODO [0/2] 53 Contributing to Emacs Development
***** TODO 53.1 Coding Standards
***** TODO 53.2 Copyright Assignment
