Skip to content

Latest commit

 

History

History
231 lines (204 loc) · 8.66 KB

init.org

File metadata and controls

231 lines (204 loc) · 8.66 KB

Debug Reset

<<enc>>
<<loc-files>>
<<pkg>>
<<file-vars>>
<<use-pkg>>
    (use-package org
    :ensure org-plus-contrib)
    (use-package ob
    :ensure org-plus-contrib)
(dolist (file elib-startup-files-org)
(org-babel-tangle-file (symbol-value file))
)

Some optimization

(setq load-prefer-newer t)
;;; Temporarily reduce garbage collection during startup. Inspect `gcs-done'.
(defun ambrevar/reset-gc-cons-threshold ()
  (setq gc-cons-threshold (car (get 'gc-cons-threshold 'standard-value))))
(setq gc-cons-threshold (* 64 1024 1024))
(add-hook 'after-init-hook #'ambrevar/reset-gc-cons-threshold)

;;; Temporarily disable the file name handler.
;; (setq default-file-name-handler-alist file-name-handler-alist)
;; (setq file-name-handler-alist nil)
;; (defun ambrevar/reset-file-name-handler-alist ()
;;   (setq file-name-handler-alist
;; 	(append default-file-name-handler-alist
;; 		file-name-handler-alist))
;;   (cl-delete-duplicates file-name-handler-alist :test 'equal))
;; (add-hook 'after-init-hook #'ambrevar/reset-file-name-handler-alist)

See selection-coding-system. Important for clipmon

(setq-default selection-coding-system 'utf-8)
(set-terminal-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8)
(set-language-environment "UTF-8")
(setq locale-coding-system 'utf-8)
(set-selection-coding-system 'utf-8)
(prefer-coding-system 'utf-8)

Initialization of Emacs

Dealing with local files

(defcustom user-emacs-config-directory
  (file-name-as-directory 
  (expand-file-name "~/.config/emacs/"))
	  "The emacs configuration directory."
	  :type 'string
	  :group :elib-file-paths)
  (setq user-emacs-directory
	   (file-name-as-directory
	    (expand-file-name (concat
			       "~/.config/emacs/"
			       "machine-local-files"))))

  (defalias 'yes-or-no-p 'y-or-n-p)
  (setq recentf-save-file (expand-file-name "recentf" user-emacs-directory))
   (setq auto-save-list-file-prefix (concat
   user-emacs-directory "auto-save-list/.saves"))
   (setq auto-revert-verbose nil)
(setq custom-file (concat user-emacs-directory "emacs-managed-customizations.el"))

Package.el

Before emacs 27, package.el needed to be initalized which was done by inserting a call to package-initialize. This is no longer needed!

 (if (< 27 emacs-major-version)
     (package-initialize))
(setq package-user-dir (expand-file-name (concat
user-emacs-directory "elpa/")))
  (require 'package)
   (add-to-list 'package-archives '("melpa"
		  . "https://melpa.org/packages/") t)
   (add-to-list 'package-archives '("org"
		  . "https://orgmode.org/elpa/") t)

   ;; (package-initialize)
  (defvar elib-init-needs-installation?
	  (null (ignore-errors (directory-files
	  package-user-dir))))
	  (setq use-package-always-ensure t)

Variables for initialization files

 (defvar elib-startup-files)
 (defvar elib-startup-files-org)
 (defvar elib-startup-files-el)
 (defvar elib-tangle-needs-to-tangle? nil)
 (defun elib-create-startup-pair (list)
   (setq elib-startup-files nil elib-startup-files-org nil elib-startup-files-el nil)
   (let ((el-file)
	  (org-file)
	  (el-file-symbol)
	  (org-file-symbol))
     (dolist (elt list)
	(setq el-file-symbol (intern (concat "elib-init-" elt "-el")))
	(setq org-file-symbol (intern (concat "elib-init-" elt "-org")))
	(setq el-file (expand-file-name (concat (concat elt ".el")) user-emacs-config-directory))
	(setq org-file (expand-file-name (concat (concat elt ".org")) user-emacs-config-directory))
	(eval `(defvar ,el-file-symbol ,el-file))
	(eval `(defvar ,org-file-symbol ,org-file))
	(when (file-newer-than-file-p org-file el-file)
	  (setq elib-tangle-needs-to-tangle? t))
     (add-to-list 'elib-startup-files (cons org-file-symbol el-file-symbol))
     (add-to-list 'elib-startup-files-org org-file-symbol)
     (add-to-list 'elib-startup-files-el el-file-symbol)
     (print elib-startup-files)
 )
 ))

 (elib-create-startup-pair '("init" "custom" "custom_functions" "configuration" "keybindings"  "load-external"));  "init-exwm"

Old

(defvar elib-init-startup-org (expand-file-name
(concat user-emacs-config-directory "init.org")))
		     (defvar elib-init-startup-el (expand-file-name

		     (concat user-emacs-config-directory "init.el")))	  (defvar elib-init-custom-org (expand-file-name
(defvar elib-init-custom-org (expand-file-name			      (concat user-emacs-config-directory "custom.org")))
		     (concat user-emacs-config-directory "custom.org")))	  (defvar elib-init-custom-el (expand-file-name
(defvar elib-init-custom-el (expand-file-name			      (concat user-emacs-config-directory "custom.el")))
		     (concat user-emacs-config-directory "custom.el")))	  (defvar elib-init-config-org (expand-file-name
(defvar elib-init-config-org (expand-file-name			      (concat user-emacs-config-directory "configuration.org")))
		     (concat user-emacs-config-directory "configuration.org")))	  (defvar elib-init-config-el (expand-file-name
(defvar elib-init-config-el (expand-file-name			      (concat user-emacs-config-directory "configuration.el")))
		     (concat user-emacs-config-directory "configuration.el")))	  (defvar elib-init-exwm-org (expand-file-name
(defvar elib-init-exwm-org (expand-file-name			      (concat user-emacs-config-directory "init-exwm.org")))
		     (concat user-emacs-config-directory "init-exwm.org")))	  (defvar elib-init-exwm-el (expand-file-name
(defvar elib-init-exwm-el (expand-file-name			     (concat user-emacs-config-directory "init-exwm.el")))
		    (concat user-emacs-config-directory "init-exwm.el")))	

  (defvar elib-tangle-needs-to-tangle?
(defvar elib-tangle-needs-to-tangle?	    (or 
  (or 	    (file-newer-than-file-p elib-init-startup-org
  (file-newer-than-file-p elib-init-startup-org					elib-init-startup-el)
                              elib-init-startup-el)	    (file-newer-than-file-p elib-init-config-org
  (file-newer-than-file-p elib-init-config-org					elib-init-config-el)
                              elib-init-config-el)	    (file-newer-than-file-p elib-init-config-org
  (file-newer-than-file-p elib-init-config-org					elib-init-config-el)
                              elib-init-config-el)		(file-newer-than-file-p elib-init-custom-org
      (file-newer-than-file-p elib-init-custom-org					elib-init-custom-el)
                              elib-init-custom-el)		(file-newer-than-file-p elib-init-exwm-org
      (file-newer-than-file-p elib-init-exwm-org					elib-init-exwm-el)
                              elib-init-exwm-el)					elib-init-needs-installation?
			       elib-init-needs-installation?		))
      ))	

Use Package

  ;; (when elib-init-needs-installation?
  ;;   (save-window-excursion
  ;;     (load-file (concat user-emacs-config-directory "packages.el"))
  ;;     (elib-do-install-packages)))
(setq use-package-always-ensure t)
(package-install 'use-package)
  (require 'use-package)
  (use-package diminish)
  (use-package bind-key)

Tangle org mode files when needed

(if elib-tangle-needs-to-tangle?
(progn
(use-package org
:ensure org-plus-contrib)
(use-package ob
:ensure org-plus-contrib)
(org-babel-tangle-file elib-init-init-org)
(org-babel-tangle-file elib-init-custom-org)
(org-babel-tangle-file elib-init-configuration-org)
(org-babel-tangle-file elib-init-custom_functions-org) 
(org-babel-tangle-file elib-init-keybindings-org)
(org-babel-tangle-file elib-init-load-external-org)
(use-package restart-emacs)
(restart-emacs)))
(progn
  (load elib-init-custom_functions-el)
  (load elib-init-custom-el)
  (load elib-init-load-external-el)
  (load elib-init-configuration-el)
  (load-file elib-init-keybindings-el))