Emacs : fix use-package start

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

View File

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