Emacs : fix use-package start

This commit is contained in:
2023-01-13 20:53:47 +09:00
parent 20746006da
commit e9692f736f

View File

@ -10,9 +10,16 @@ Emacs Configuration for emacs 29.50
;; prefers newest version of a file ;; prefers newest version of a file
(customize-set-variable 'load-prefer-newer t) (customize-set-variable 'load-prefer-newer t)
(setq package-enable-at-startup nil ;;; Native compilation settings
inhibit-startup-message t frame-resize-pixelwise t (when (featurep 'native-compile)
package-native-compile t) ;; Silence compiler warnings as they can be pretty disruptive
(setq native-comp-async-report-warnings-errors nil)
;; Make native compilation happens asynchronously
(setq native-comp-deferred-compilation t))
(setq inhibit-startup-message t)
(setq frame-resize-pixelwise t)
(scroll-bar-mode -1) (scroll-bar-mode -1)
(tool-bar-mode -1) (tool-bar-mode -1)
(tooltip-mode -1) (tooltip-mode -1)
@ -36,30 +43,28 @@ Emacs Configuration for emacs 29.50
(message "Crafted Emacs loaded in %s" (message "Crafted Emacs loaded in %s"
(emacs-init-time)))) (emacs-init-time))))
#+end_src #+end_src
*** Straight *** Package Function
#+begin_src emacs-lisp :tangle ~/.config/emacs/init.el #+begin_src emacs-lisp :tangle ~/.config/emacs/init.el
(require 'package) (require 'package)
(add-to-list 'package-archives '("stable" . "https://stable.melpa.org/packages/")) (add-to-list 'package-archives '("stable" . "https://stable.melpa.org/packages/"))
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/")) (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/"))
(defvar bootstrap-version) (customize-set-variable 'package-archive-priorities
(let ((bootstrap-file '(("gnu" . 99) ; prefer GNU packages
(expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory)) ("nongnu" . 80) ; use non-gnu packages if
(bootstrap-version 5)) ; not found in GNU elpa
(unless (file-exists-p bootstrap-file) ("stable" . 70) ; prefer "released" versions
(with-current-buffer ; from melpa
(url-retrieve-synchronously ("melpa" . 0))) ; if all else fails, get it
"https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el" ; from melpa
'silent 'inhibit-cookies) ;; make sure the elpa/ folder exists after setting it above.
(goto-char (point-max)) (unless (file-exists-p package-user-dir)
(eval-print-last-sexp))) (mkdir package-user-dir t))
(load bootstrap-file nil 'nomessage))
(setq straight-use-package-by-default t)
(package-initialize)
(unless package-archive-contents
(package-refresh-contents))
(straight-use-package '(use-package :build t))
(setq use-package-always-ensure t)
(defmacro usr-package-install (package)
`(unless (package-installed-p ,package) (package-install ,package)))
(package-initialize)
;;; init.el ends here
#+end_src #+end_src
*** Add other modules *** Add other modules
#+begin_src emacs-lisp :tangle ~/.config/emacs/init.el #+begin_src emacs-lisp :tangle ~/.config/emacs/init.el
@ -119,9 +124,9 @@ Emacs Configuration for emacs 29.50
trash-directory "~/.local/share/Trash/files/") trash-directory "~/.local/share/Trash/files/")
(setq undo-limit 100000000 (setq undo-limit 100000000
auto-save-default t) auto-save-default t)
(use-package no-littering) ;;(require 'no-littering)
(setq auto-save-file-name-transforms ;;(setq auto-save-file-name-transforms
`((".*" ,(no-littering-expand-var-file-name "auto-save/") t))) ;; `((".*" ,(no-littering-expand-var-file-name "auto-save/") t)))
#+end_src #+end_src
*** Other options *** Other options
@ -136,8 +141,7 @@ Emacs Configuration for emacs 29.50
(setq gc-cons-threshold (* 2 1024 1024)) ; decreasing the threshold to 2MB (setq gc-cons-threshold (* 2 1024 1024)) ; decreasing the threshold to 2MB
(defvar my-config-file (expand-file-name "config.el" user-emacs-directory)) (defvar my-config-file (expand-file-name "config.el" user-emacs-directory))
(when (file-exists-p my-config-file) (load my-config-file nil 'nomessage)
(load my-config-file nil 'nomessage))
(setq use-short-answer t) (setq use-short-answer t)
(global-auto-revert-mode t) (global-auto-revert-mode t)
@ -154,20 +158,22 @@ Emacs Configuration for emacs 29.50
(add-hook 'emacs-startup-hook (add-hook 'emacs-startup-hook
(lambda () (lambda ()
(custom-set-faces (custom-set-faces
`(default ((t (:font "Fira Code 10")))) `(default ((t (:font "Fira Code 14"))))
`(fixed-pitch ((t (:inherit (default))))) `(fixed-pitch ((t (:inherit (default)))))
`(fixed-pitch-serif ((t (:inherit (default))))) `(fixed-pitch-serif ((t (:inherit (default)))))
`(variable-pitch ((t (:font "Ubuntu 10"))))))) `(variable-pitch ((t (:font "Ubuntu 14")))))))
(require 'custom-ui) (require 'custom-ui)
(require 'custom-keybindings) ;;(require 'custom-keybindings)
(require 'custom-default) ;;(require 'custom-default)
(require 'custom-org) ;;(require 'custom-org)
(require 'custom-completion) ;;(require 'custom-completion)
(require 'custom-projects) ;;(require 'custom-projects)
;;(require 'custom-workspaces) ;;(require 'custom-workspaces)
(require 'custom-latex) ;;(require 'custom-latex)
(require 'custom-extra) ;;(require 'custom-extra)
;;; config.el ends here
#+end_src #+end_src
** Module Lists ** Module Lists
@ -248,21 +254,29 @@ emacs built-in package config
;;; custom-default.el ends here ;;; custom-default.el ends here
#+end_src #+end_src
*** UI *** UI
**** Install Packages
#+begin_src emacs-lisp :mkdirp yes :tangle ~/.config/emacs/modules/custom-ui.el
(usr-package-install 'doom-themes)
(usr-package-install 'rainbow-delimiters)
(usr-package-install 'all-the-icons)
(usr-package-install 'doom-modeline)
(usr-package-install 'visual-fill-column)
#+end_src
**** Doom themes **** Doom themes
#+begin_src emacs-lisp :mkdirp yes :tangle ~/.config/emacs/modules/custom-ui.el #+begin_src emacs-lisp :mkdirp yes :tangle ~/.config/emacs/modules/custom-ui.el
(use-package doom-themes) (require 'doom-themes)
(disable-theme 'deeper-blue)
(if (display-graphic-p) (if (display-graphic-p)
(load-theme 'doom-palenight t) (load-theme 'doom-palenight t)
(load-theme 'doom-gruvbox t)) (load-theme 'doom-gruvbox t))
#+end_src #+end_src
**** Rainbow Delimiters **** Rainbow Delimiters
#+begin_src emacs-lisp :mkdirp yes :tangle ~/.config/emacs/modules/custom-ui.el #+begin_src emacs-lisp :mkdirp yes :tangle ~/.config/emacs/modules/custom-ui.el
(use-package rainbow-delimiters (require 'rainbow-delimiters)
:hook (prog-mode . rainbow-delimiters-mode)) (add-hook 'prog-mode rainbow-delimiters-mode)
#+end_src #+end_src
**** Setting Transparency **** Setting Transparency
#+begin_src emacs-lisp :mkdirp yes :tangle ~/.config/emacs/modules/custom-ui.el #+begin_src emacs-lisp :mkdirp yes :tangle ~/.config/emacs/modules/custom-ui.el
(setq visible-bell t)
(set-frame-parameter nil 'alpha-background 0.9) (set-frame-parameter nil 'alpha-background 0.9)
(add-to-list 'default-frame-alist '(alpha-background . 0.9)) (add-to-list 'default-frame-alist '(alpha-background . 0.9))
(defun toggle-transparency () (defun toggle-transparency ()
@ -299,17 +313,15 @@ emacs built-in package config
#+end_src #+end_src
**** Modeline **** Modeline
#+begin_src emacs-lisp :mkdirp yes :tangle ~/.config/emacs/modules/custom-ui.el #+begin_src emacs-lisp :mkdirp yes :tangle ~/.config/emacs/modules/custom-ui.el
(use-package all-the-icons) (require 'doom-modeline)
(use-package doom-modeline
:init
(doom-modeline-mode 1)
:config
(setq doom-modeline-height 15 (setq doom-modeline-height 15
doom-modeline-env-version t doom-modeline-env-version t
doom-modeline-persp-name t doom-modeline-persp-name t
doom-modeline-persp-icon t doom-modeline-persp-icon t
doom-modeline-display-default-persp-name t doom-modeline-display-default-persp-name t
doom-modeline-indent-info t)) doom-modeline-indent-info t)
(doom-modeline-mode 1)
#+end_src #+end_src
**** Whiteroom **** Whiteroom
#+begin_src emacs-lisp :mkdirp yes :tangle ~/.config/emacs/modules/custom-ui.el #+begin_src emacs-lisp :mkdirp yes :tangle ~/.config/emacs/modules/custom-ui.el
@ -326,57 +338,57 @@ emacs built-in package config
#+end_src #+end_src
**** Visual Fill Column **** Visual Fill Column
#+begin_src emacs-lisp :mkdirp yes :tangle ~/.config/emacs/modules/custom-ui.el #+begin_src emacs-lisp :mkdirp yes :tangle ~/.config/emacs/modules/custom-ui.el
(require 'visual-fill-column)
(defun write-room-enable () (defun write-room-enable ()
(setq visual-fill-column-width 100 (setq visual-fill-column-width 100
visual-fill-column-center-text t) visual-fill-column-center-text t)
(visual-fill-column-mode 1)) (add-hook 'org-mode write-room-enable)
(use-package visual-fill-column (add-hook 'markdown-mode write-room-enable)
:hook (add-hook 'nov-mode write-room-enable)
(org-mode . write-room-enable)
;;(text-mode . write-room-enable) (visual-fill-column-mode 1)
(markdown-mode . write-room-enable)
(nov-mode . write-room-enable))
#+end_src #+end_src
**** Dashboard **** Dashboard
#+begin_src emacs-lisp :mkdirp yes :tangle ~/.config/emacs/modules/custom-ui.el #+begin_src emacs-lisp :mkdirp yes :tangle ~/.config/emacs/modules/custom-ui.el
(use-package page-break-lines) ;;; (use-package page-break-lines)
(use-package dashboard ;; (use-package dashboard
:init ;; tweak dashboard config before loading it ;; :init ;; tweak dashboard config before loading it
(setq dashboard-projects-backend `project-el ;; (setq dashboard-projects-backend `project-el
dashboard-set-heading-icons t ;; dashboard-set-heading-icons t
dashboard-set-file-icons t ;; dashboard-set-file-icons t
dashboard-center-content t ;; set to 't' for centered content ;; dashboard-center-content t ;; set to 't' for centered content
dashboard-items '((recents . 10) ;; dashboard-items '((recents . 10)
(bookmarks . 5) ;; (bookmarks . 5)
(projects . 10)) ;; (projects . 10))
dashboard-set-footer t ;; dashboard-set-footer t
dashboard-page-separator "\n\f\n" ;; dashboard-page-separator "\n\f\n"
dashboard-set-navigator t) ;; dashboard-set-navigator t)
;;
(setq dashboard-startup-banner 'logo) ;; (setq dashboard-startup-banner 'logo)
;;(setq dashboard-startup-banner "~/.dotfiles/.config/emacs/logo3d.png") ;; ;;(setq dashboard-startup-banner "~/.dotfiles/.config/emacs/logo3d.png")
;; Format: "(icon title help action face prefix suffix)" ;; ;; Format: "(icon title help action face prefix suffix)"
(setq dashboard-navigator-buttons ;; (setq dashboard-navigator-buttons
`(;; line1 ;; `(;; line1
((,(all-the-icons-octicon "mark-github" :height 1.1 :v-adjust 0.0) ;; ((,(all-the-icons-octicon "mark-github" :height 1.1 :v-adjust 0.0)
"Github" ;; "Github"
"Browse my Github" ; "Browse my Github"
(lambda (&rest _) (browse-url "https://github.com/JaeUs3792/"))) ;; (lambda (&rest _) (browse-url "https://github.com/JaeUs3792/")))
(,(all-the-icons-octicon "home" :height 1.1 :v-adjust 0.0) ; (,(all-the-icons-octicon "home" :height 1.1 :v-adjust 0.0)
"Homepage" ; "Homepage"
"Browse my Homepage" ; "Browse my Homepage"
(lambda (&rest _) (browse-url "https://jaeus.net")))))) ; (lambda (&rest _) (browse-url "https://jaeus.net"))))))
:config ; :config
(dashboard-setup-startup-hook) ; (dashboard-setup-startup-hook)
(dashboard-modify-heading-icons '((recents . "file-text") ; (dashboard-modify-heading-icons '((recents . "file-text")
(bookmarks . "book")))) ; (bookmarks . "book"))))
(setq doom-fallback-buffer-name "*dashboard*") ; (setq doom-fallback-buffer-name "*dashboard*")
#+end_src #+end_src
**** Others **** Others
#+begin_src emacs-lisp :mkdirp yes :tangle ~/.config/emacs/modules/custom-ui.el #+begin_src emacs-lisp :mkdirp yes :tangle ~/.config/emacs/modules/custom-ui.el
(setq visible-bell t)
(defun self-screenshot (&optional type) (defun self-screenshot (&optional type)
"Save a screenshot of type TYPE of the current Emacs frame. "Save a screenshot of type TYPE of the current Emacs frame.
As shown by the function `', type can weild the value `svg', As shown by the function `', type can weild the value `svg',
@ -413,7 +425,7 @@ and ending with the extension of the requested TYPE."
**** Global Key **** Global Key
#+begin_src emacs-lisp :mkdirp yes :tangle ~/.config/emacs/modules/custom-keybindings.el #+begin_src emacs-lisp :mkdirp yes :tangle ~/.config/emacs/modules/custom-keybindings.el
(global-set-key (kbd "C-c t") 'toggle-transparency) (global-set-key (kbd "C-c t") 'toggle-transparency)
(global-set-key (kbd "C-M-j") 'consult-buffer) ;;(global-set-key (kbd "C-M-j") 'consult-buffer)
;; Make ESC quit prompts ;; Make ESC quit prompts
(global-set-key (kbd "<escape>") 'keyboard-escape-quit) (global-set-key (kbd "<escape>") 'keyboard-escape-quit)
@ -762,10 +774,10 @@ get link from pdf,
*** Projects *** Projects
**** MAGIT **** MAGIT
#+begin_src emacs-lisp :mkdirp yes :tangle ~/.config/emacs/modules/custom-projects.el #+begin_src emacs-lisp :mkdirp yes :tangle ~/.config/emacs/modules/custom-projects.el
(use-package magit (use-package magit)
:commands (magit-status magit-get-current-branch) ;;:commands (magit-status magit-get-current-branch)
:custom ;;:custom
(magit-display-buffer-function #'magit-display-buffer-same-window-except-diff-v1)) ;;(magit-display-buffer-function #'magit-display-buffer-same-window-except-diff-v1))
(use-package magit-todos (use-package magit-todos
:after (magit todo) :after (magit todo)
:config :config