<commit_before>#+TITLE: Emacs configuration file
#+AUTHOR: <NAME>
#+BABEL: :cache yes

* Packages
** Package Repositories
#+BEGIN_SRC emacs-lisp
(require 'package)
(setq package-enable-at-startup nil)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
(add-to-list 'package-archives '("org" . "http://orgmode.org/elpa/") t)
(package-initialize)
(unless (package-installed-p 'use-package)
  (package-refresh-contents)
  (package-install 'use-package))
(eval-when-compile
  (require 'use-package))
;;(use-package benchmark-init
;;  :ensure t
;;  :config
;;  ;; To disable collection of benchmark data after init is done.
;;  (add-hook 'after-init-hook 'benchmark-init/deactivate))
(server-start)
#+END_SRC

** Mac OS
#+BEGIN_SRC emacs-lisp
(when (memq window-system '(mac ns))
  (setq ns-pop-up-frames nil
        x-select-enable-clIpboard t)
(use-package exec-path-from-shell
  :if (memq window-system '(mac ns))
  :ensure t
  :config (exec-path-from-shell-initialize))
  (when (fboundp 'mac-auto-operator-composition-mode)
    (mac-auto-operator-composition-mode 1)))'
#+END_SRC
** Security
   Inspired by [[https://ogbe.net/emacsconfig.html][ogbe.net]] and [[https://glyph.twistedmatrix.com/2015/11/editor-malware.html][Your Text Editor Is Malware]].
*** Check TLS
#+BEGIN_SRC emacs-lisp
  (setq tls-checktrust t)
  (setq gnutls-verify-error t)
#+END_SRC

** Automatic package installation
*** Install =use-package=
And its dependencies if needed.
#+BEGIN_SRC emacs-lisp
(mapc
 (lambda (package)
   (if (not (package-installed-p package))
       (progn
         (package-refresh-contents)
         (package-install package))))
 '(use-package diminish bind-key))
#+END_SRC
*** Trigger =use-package=
And force the install of missing packages.
#+BEGIN_SRC emacs-lisp
(eval-when-compile
  (require 'use-package))
(require 'diminish)
(require 'bind-key)
(setq use-package-always-ensure t)
#+END_SRC
** My information
 All the relevant and personal information that Emacs needs. If you are going to
 use it, needless to say to use your own information.

 #+BEGIN_SRC emacs-lisp :results silent
 (setq user-full-name "<NAME>"
       user-mail-address "<EMAIL>"
       calendar-latitude 53.42
       calendar-longitude -7.94
       calendar-location-name "Athlone, Ireland")
 #+END_SRC

* Theme
 #+BEGIN_SRC emacs-lisp
(use-package solarized-theme :config (load-theme 'solarized-dark t))
#+END_SRC

* Quickly edit this config file
#+BEGIN_SRC emacs-lisp
  (defun edit-config-file ()
    (interactive)
    (find-file (concat config-load-path "emacs-init.org")))
#+END_SRC

* Defaults
** Backup and autosave
By default, emacs writes a backup file next to the file being editing
with a trailing =~= turd.
#+BEGIN_SRC emacs-lisp
;; store all autosave files in the tmp dir
(setq auto-save-file-name-transforms
      `((".*" ,temporary-file-directory t)))

;; backups in backup dir
(setq backup-by-copying t
      backup-directory-alist '(("." . "~/.emacs.d/backup"))
      delete-old-versions t
      kept-new-versions 24
      kept-old-versions 12
      version-control t)

(setq create-lockfiles nil)
#+END_SRC

** Require
Some features are not loaded by default to minimize initialization time,
so they have to be required (or loaded, if you will). =require=-calls
tends to lead to the largest bottleneck's in a
configuration. =idle-require= delays the =require=-calls to a time where
Emacs is in idle. So this is great for stuff you eventually want to load,
but is not a high priority.

#+BEGIN_SRC emacs-lisp
(use-package recentf
    :defer 1
    :config (recentf-mode 1)
(setq recentf-max-menu-items 300)
(setq recentf-max-saved-items 300)
(setq recentf-exclude
   '("/elpa/" ;; ignore all files in elpa directory
     "recentf" ;; remove the recentf load file
     ".*?autoloads.el$"
     "treemacs-persist"
     "company-statistics-cache.el" ;; ignore company cache file
     "/intero/" ;; ignore script files generated by intero
     "/journal/" ;; ignore daily journal files
     ".gitignore" ;; ignore `.gitignore' files in projects
     "/tmp/" ;; ignore temporary files
     "NEWS" ;; don't include the NEWS file for recentf
     "bookmarks"  "bmk-bmenu" ;; ignore bookmarks file in .emacs.d
     "loaddefs.el"
     "^/\\(?:ssh\\|su\\|sudo\\)?:" ;; ignore tramp/ssh files
     ))
(setq-default recent-save-file "~/.emacs.d/recentf"))
#+END_SRC
** Disable GUI Elements
#+BEGIN_SRC emacs-lisp
(if (fboundp 'scroll-bar-mode) (scroll-bar-mode -1))
(if (fboundp 'tool-bar-mode) (tool-bar-mode -1))
#+END_SRC
** Disable splash screen
And set it in emacs-lisp mode
#+BEGIN_SRC emacs-lisp
(setq inhibit-startup-message t)
(setq initial-major-mode 'emacs-lisp-mode)
#+END_SRC
** Empty Scratch buffer
#+BEGIN_SRC emacs-lisp
(setq initial-scratch-message nil)
#+END_SRC

* Helm
#+BEGIN_SRC emacs-lisp<commit_msg>Added pdf-tools to emacs<commit_after>#+TITLE: Emacs configuration file
#+AUTHOR: <NAME>
#+BABEL: :cache yes

* Packages
** Package Repositories
#+BEGIN_SRC emacs-lisp
(require 'package)
(setq package-enable-at-startup nil)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
(add-to-list 'package-archives '("org" . "http://orgmode.org/elpa/") t)
(package-initialize)
(unless (package-installed-p 'use-package)
  (package-refresh-contents)
  (package-install 'use-package))
(eval-when-compile
  (require 'use-package))
;;(use-package benchmark-init
;;  :ensure t
;;  :config
;;  ;; To disable collection of benchmark data after init is done.
;;  (add-hook 'after-init-hook 'benchmark-init/deactivate))
(server-start)
#+END_SRC

** Mac OS
#+BEGIN_SRC emacs-lisp
(when (memq window-system '(mac ns))
  (setq ns-pop-up-frames nil
        x-select-enable-clIpboard t)
(use-package exec-path-from-shell
  :if (memq window-system '(mac ns))
  :ensure t
  :config (exec-path-from-shell-initialize))
  (when (fboundp 'mac-auto-operator-composition-mode)
    (mac-auto-operator-composition-mode 1)))'
#+END_SRC
** Security
   Inspired by [[https://ogbe.net/emacsconfig.html][ogbe.net]] and [[https://glyph.twistedmatrix.com/2015/11/editor-malware.html][Your Text Editor Is Malware]].
*** Check TLS
#+BEGIN_SRC emacs-lisp
  (setq tls-checktrust t)
  (setq gnutls-verify-error t)
#+END_SRC

** Automatic package installation
*** Install =use-package=
And its dependencies if needed.
#+BEGIN_SRC emacs-lisp
(mapc
 (lambda (package)
   (if (not (package-installed-p package))
       (progn
         (package-refresh-contents)
         (package-install package))))
 '(use-package diminish bind-key))
#+END_SRC
*** Trigger =use-package=
And force the install of missing packages.
#+BEGIN_SRC emacs-lisp
(eval-when-compile
  (require 'use-package))
(require 'diminish)
(require 'bind-key)
(setq use-package-always-ensure t)
#+END_SRC
** My information
 All the relevant and personal information that Emacs needs. If you are going to
 use it, needless to say to use your own information.

 #+BEGIN_SRC emacs-lisp :results silent
 (setq user-full-name "<NAME>"
       user-mail-address "<EMAIL>"
       calendar-latitude 53.42
       calendar-longitude -7.94
       calendar-location-name "Athlone, Ireland")
 #+END_SRC

* Theme
 #+BEGIN_SRC emacs-lisp
(use-package solarized-theme :config (load-theme 'solarized-dark t))
#+END_SRC

* Quickly edit this config file
#+BEGIN_SRC emacs-lisp
  (defun edit-config-file ()
    (interactive)
    (find-file (concat config-load-path "emacs-init.org")))
#+END_SRC

* Defaults
** Backup and autosave
By default, emacs writes a backup file next to the file being editing
with a trailing =~= turd.
#+BEGIN_SRC emacs-lisp
;; store all autosave files in the tmp dir
(setq auto-save-file-name-transforms
      `((".*" ,temporary-file-directory t)))

;; backups in backup dir
(setq backup-by-copying t
      backup-directory-alist '(("." . "~/.emacs.d/backup"))
      delete-old-versions t
      kept-new-versions 24
      kept-old-versions 12
      version-control t)

(setq create-lockfiles nil)
#+END_SRC

** Require
Some features are not loaded by default to minimize initialization time,
so they have to be required (or loaded, if you will). =require=-calls
tends to lead to the largest bottleneck's in a
configuration. =idle-require= delays the =require=-calls to a time where
Emacs is in idle. So this is great for stuff you eventually want to load,
but is not a high priority.

#+BEGIN_SRC emacs-lisp
(use-package recentf
    :defer 1
    :config (recentf-mode 1)
(setq recentf-max-menu-items 300)
(setq recentf-max-saved-items 300)
(setq recentf-exclude
   '("/elpa/" ;; ignore all files in elpa directory
     "recentf" ;; remove the recentf load file
     ".*?autoloads.el$"
     "treemacs-persist"
     "company-statistics-cache.el" ;; ignore company cache file
     "/intero/" ;; ignore script files generated by intero
     "/journal/" ;; ignore daily journal files
     ".gitignore" ;; ignore `.gitignore' files in projects
     "/tmp/" ;; ignore temporary files
     "NEWS" ;; don't include the NEWS file for recentf
     "bookmarks"  "bmk-bmenu" ;; ignore bookmarks file in .emacs.d
     "loaddefs.el"
     "^/\\(?:ssh\\|su\\|sudo\\)?:" ;; ignore tramp/ssh files
     ))
(setq-default recent-save-file "~/.emacs.d/recentf"))
#+END_SRC
** Disable GUI Elements
#+BEGIN_SRC emacs-lisp
(if (fboundp 'scroll-bar-mode) (scroll-bar-mode -1))
(if (fboundp 'tool-bar-mode) (tool-bar-mode -1))
#+END_SRC
** Disable splash screen
And set it in emacs-lisp mode
#+BEGIN_SRC emacs-lisp
(setq inhibit-startup-message t)
(setq initial-major-mode 'emacs-lisp-mode)
#+END_SRC
** Empty Scratch buffer
#+BEGIN_SRC emacs-lisp
(setq initial-scratch-message nil)
#+END_SRC

* PDF Tools
#+BEGIN_SRC emacs-lisp
(use-package pdf-tools
  :if (not (string-equal system-type "windows-nt"))
  :mode (("\\.pdf\\'" . pdf-view-mode))
  :functions (pdf-tools-disable-cursor pdf-tools-advice-evil-refresh-cursor))
#+END_SRC

* Helm
#+BEGIN_SRC emacs-lisp
{'fraction_non_alphanumeric': 0.14092469210579447, 'fraction_numerical': 0.005653139511407228, 'mean_word_length': 3.8421309872922778, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '635320', 'n_tokens_mistral': 3584, 'n_tokens_neox': 3425, 'n_words': 972}