Skip to content

Commit

Permalink
refactor: move more settings to me-builtin
Browse files Browse the repository at this point in the history
  • Loading branch information
abougouffa committed Jul 13, 2023
1 parent 285f46c commit dcf61b7
Show file tree
Hide file tree
Showing 2 changed files with 148 additions and 108 deletions.
144 changes: 144 additions & 0 deletions core/me-builtin.el
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,17 @@
(tramp-persistency-file-name (concat minemacs-local-dir "tramp/persistency.el"))
(tramp-default-remote-shell "/bin/bash"))

(use-package eshell
:straight (:type built-in)
:custom
(eshell-aliases-file (concat minemacs-local-dir "eshell/aliases"))
(eshell-directory-name (+directory-ensure minemacs-local-dir "eshell/"))
(eshell-history-file-name (concat minemacs-local-dir "eshell/history.el"))
(eshell-last-dir-ring-file-name (concat minemacs-local-dir "eshell/last-dir-ring.el"))
(eshell-login-script (concat minemacs-local-dir "eshell/login"))
(eshell-rc-script (concat minemacs-local-dir "eshell/rc"))
(eshell-scroll-to-bottom-on-input 'this))

(use-package reftex ;; Inspired by Doom Emacs
:straight (:type built-in)
:hook (LaTeX-mode . turn-on-reftex)
Expand Down Expand Up @@ -290,6 +301,13 @@
:mode "CMakeLists\\.txt\\'"
:mode "\\.cmake\\'"))

(use-package autoinsert
;; NOTE: When prompting (like in Keywords), hit M-RET when finished
:straight (:type built-in)
:hook (minemacs-after-startup . auto-insert-mode)
:custom
(auto-insert-directory (+directory-ensure minemacs-local-dir "auto-insert/")))

(use-package hideif
:straight (:type built-in)
:init
Expand Down Expand Up @@ -787,6 +805,132 @@
(list (concat (buffer-substring-no-properties (point) opoint) "\n")))
(mapconcat 'identity inferior-octave-output-list "\n"))))))

(use-package abbrev
:straight (:type built-in)
:custom
(abbrev-file-name (concat minemacs-local-dir "abbrev.el")))

(use-package bookmark
:straight (:type built-in)
:custom
(bookmark-default-file (concat minemacs-local-dir "bookmark.el"))
;; Save the bookmarks every time a bookmark is made
(bookmark-save-flag 1))

(use-package calc
:straight (:type built-in)
:init
(+map! "o=" #'calc)
:custom
(calc-settings-file (concat minemacs-local-dir "calc-settings.el")))

(use-package desktop
:straight (:type built-in)
:hook (minemacs-after-startup . desktop-save-mode)
:custom
;; File name to use when saving desktop
(desktop-base-file-name "emacs-session.el")
;; File name to use as a lock
(desktop-base-lock-name (concat desktop-base-file-name ".lock"))
;; Load only 5 buffers immediately, the remaining buffers will be loaded lazily
(desktop-restore-eager 5)
;; Avoid writing contents unchanged between auto-saves
(desktop-file-checksum t)
;; Save buffer status
(desktop-save-buffer t))

(use-package recentf
:straight (:type built-in)
:after minemacs-loaded
:demand t
:custom
(recentf-save-file (concat minemacs-local-dir "recentf-save.el"))
;; Increase the maximum number of saved items
(recentf-max-saved-items 100)
;; Ignore case when searching recentf files
(recentf-case-fold-search t)
;; Exclude some files from being remembered by recentf
(recentf-exclude
`(,(rx (* any)
(or
"elfeed-db"
"eln-cache"
"/cache/"
".maildir/"
".cache/")
(* any)
(? (or "html" "pdf" "tex" "epub")))
,(rx "/"
(or "rsync" "ssh" "tmp" "yadm" "sudoedit" "sudo")
(* any))))
:config
;; Enable `recentf-mode' to remember recent files
(+shutup! (recentf-mode 1)))

(use-package url
:straight (:type built-in)
:custom
(url-cache-directory (+directory-ensure minemacs-cache-dir "url/"))
(url-configuration-directory (+directory-ensure minemacs-local-dir "url/"))
(url-cookie-file (concat minemacs-local-dir "url/cookie.el"))
(url-history-file (concat minemacs-local-dir "url/history.el")))

(use-package webjump
:straight (:type built-in)
:custom
(webjump-sites
'(("Emacs Wiki" . [simple-query "www.emacswiki.org" "www.emacswiki.org/cgi-bin/wiki/" ""])
("DuckDuckGo" . [simple-query "duckduckgo.com" "duckduckgo.com/?q=" ""])
("Qwant" . [simple-query "www.qwant.com" "www.qwant.com/?q=" ""])
("Ecosia" . [simple-query "www.ecosia.org" "www.ecosia.org/search?q=" ""])
("Brave" . [simple-query "search.brave.com" "search.brave.com/search?q=" ""])
("Bing" . [simple-query "www.bing.com" "www.bing.com/search?q=" ""])
("Yahoo" . [simple-query "www.yahoo.com" "search.yahoo.com/search?p=" ""])
("Google" . [simple-query "www.google.com" "www.google.com/search?q=" ""])
("Google Maps" . [simple-query "www.google.com" "www.google.com/maps?q=" ""])
("Google Images" . [simple-query "www.google.com" "www.google.com/images?q=" ""])
("Google Groups" . [simple-query "groups.google.com" "groups.google.com/groups?q=" ""])
("StackOverflow" . [simple-query "stackoverflow.com" "stackoverflow.com/search?q=" ""])
("GitHub Repo" . [simple-query "github.com" "github.com/search?type=repositories&q=" ""])
("GitHub Code" . [simple-query "github.com" "github.com/search?type=code&q=" ""])
("WolframAlpha" . [simple-query "wolframalpha.com" "wolframalpha.com/input/?i=" ""])
("MDN" . [simple-query "developer.mozilla.org" "developer.mozilla.org/search?q=" ""])
("Youtube" . [simple-query "www.youtube.com" "www.youtube.com/results?search_query=" ""])
("Reddit" . [simple-query "www.reddit.com" "www.reddit.com/search/?q=" ""])
("Wikipedia" . [simple-query "wikipedia.org" "wikipedia.org/wiki/" ""]))))

(use-package time-stamp
:straight (:type built-in)
;; Update time stamp (if available) before saving a file.
:hook (before-save . time-stamp)
:custom
;; Do enable time-stamps
(time-stamp-active t)
;; Check the first 12 buffer lines for Time-stamp: <>
(time-stamp-line-limit 12)
;; Timestamp format
(time-stamp-format "%04Y-%02m-%02d %02H:%02M:%02S"))

(use-package whitespace
:straight (:type built-in)
:hook (before-save . +save--whitespace-cleanup-h)
:custom
;; Default behavior for `whitespace-cleanup'
(whitespace-action '(cleanup auto-cleanup))
:init
(defcustom +whitespace-auto-cleanup-modes
'(prog-mode conf-mode org-mode markdown-mode
latex-mode tex-mode bibtex-mode)
"Enable auto white space cleanup before saving for these derived modes."
:group 'minemacs-edit
:type '(repeat symbol))
:config
;; Auto-remove trailing white spaces before saving for modes defined in
;; `+whitespace-auto-cleanup-modes'.
(defun +save--whitespace-cleanup-h ()
(when (cl-some #'derived-mode-p +whitespace-auto-cleanup-modes)
(whitespace-cleanup))))


(provide 'me-builtin)

Expand Down
112 changes: 4 additions & 108 deletions core/me-defaults.el
Original file line number Diff line number Diff line change
Expand Up @@ -27,26 +27,15 @@

(setopt
;; ====== Default directories for builtin packages ======
abbrev-file-name (concat minemacs-local-dir "abbrev.el")
auto-insert-directory (+directory-ensure minemacs-local-dir "auto-insert/")
auto-save-list-file-prefix (+directory-ensure minemacs-local-dir "auto-save/")
backup-directory-alist (list (cons "." (+directory-ensure minemacs-local-dir "backup/")))
bookmark-default-file (concat minemacs-local-dir "bookmark.el")
calc-settings-file (concat minemacs-local-dir "calc-settings.el")
custom-theme-directory (concat minemacs-config-dir "themes/")
desktop-dirname (+directory-ensure minemacs-local-dir "desktop/")
desktop-path (list desktop-dirname)

diary-file (concat minemacs-local-dir "diary")
custom-theme-directory (concat minemacs-config-dir "themes/")
ecomplete-database-file (concat minemacs-local-dir "ecomplete-database.el")
ede-project-placeholder-cache-file (concat minemacs-local-dir "ede-projects.el")
erc-dcc-get-default-directory (+directory-ensure minemacs-local-dir "erc/dcc/")
erc-log-channels-directory (+directory-ensure minemacs-local-dir "erc/log-channels/")
eshell-aliases-file (concat minemacs-local-dir "eshell/aliases")
eshell-directory-name (+directory-ensure minemacs-local-dir "eshell/")
eshell-history-file-name (concat minemacs-local-dir "eshell/history.el")
eshell-last-dir-ring-file-name (concat minemacs-local-dir "eshell/last-dir-ring.el")
eshell-login-script (concat minemacs-local-dir "eshell/login")
eshell-rc-script (concat minemacs-local-dir "eshell/rc")
eudc-options-file (concat minemacs-local-dir "eudc-options.el")
eww-bookmarks-directory (+directory-ensure minemacs-local-dir "eww/bookmarks/")
fortune-dir (+directory-ensure minemacs-local-dir "fortune/")
Expand All @@ -63,10 +52,8 @@
newsticker-cache-filename (concat minemacs-local-dir "newsticker/cache.el")
newsticker-dir (+directory-ensure minemacs-local-dir "newsticker/data/")
nsm-settings-file (concat minemacs-local-dir "nsm-settings.el")
project-list-file (concat minemacs-local-dir "project-list.el")
quickurl-url-file (concat minemacs-local-dir "quickurl-url.el")
rcirc-log-directory (+directory-ensure minemacs-local-dir "rcirc/log/")
recentf-save-file (concat minemacs-local-dir "recentf-save.el")
remember-data-directory (+directory-ensure minemacs-local-dir "remember/data/")
remember-data-file (concat minemacs-local-dir "remember/data.el")
save-place-file (concat minemacs-local-dir "save-place.el")
Expand All @@ -78,10 +65,6 @@
srecode-map-save-file (concat minemacs-local-dir "srecode-map.el")
timeclock-file (concat minemacs-local-dir "timeclock")
type-break-file-name (concat minemacs-local-dir "type-break.el")
url-cache-directory (+directory-ensure minemacs-cache-dir "url/")
url-configuration-directory (+directory-ensure minemacs-local-dir "url/")
url-cookie-file (concat minemacs-local-dir "url/cookie.el")
url-history-file (concat minemacs-local-dir "url/history.el")

;; ====== Additional directories for non-builtin but common packages ======
pcache-directory (concat minemacs-cache-dir "pcache/")
Expand Down Expand Up @@ -188,8 +171,6 @@
;; ====== Editing ======
;; Hitting TAB behavior
tab-always-indent 'complete
;; Default behavior for `whitespace-cleanup'
whitespace-action '(cleanup auto-cleanup)
;; End files with newline
require-final-newline t
;; Enable Drag-and-Drop of regions
Expand Down Expand Up @@ -240,34 +221,6 @@
;; Make mouse scroll a little faster horizontally
mouse-wheel-scroll-amount-horizontal 2

;; ====== Recent files ======
;; Increase the maximum number of saved items
recentf-max-saved-items 100
;; Ignore case when searching recentf files
recentf-case-fold-search t
;; Exclude some files from being remembered by recentf
recentf-exclude
`(,(rx (* any)
(or
"elfeed-db"
"eln-cache"
"/cache/"
".maildir/"
".cache/")
(* any)
(? (or "html" "pdf" "tex" "epub")))
,(rx "/"
(or "rsync" "ssh" "tmp" "yadm" "sudoedit" "sudo")
(* any)))

;; ====== Timestamps ======
;; Do enable time-stamps
time-stamp-active t
;; Check the first 12 buffer lines for Time-stamp: <>
time-stamp-line-limit 12
;; Timestamp format
time-stamp-format "%04Y-%02m-%02d %02H:%02M:%02S"

;; ====== Auto-Saving, sessions ======
;; Enable auto-save (use `recover-file' or `recover-session' to recover)
auto-save-default t
Expand All @@ -278,38 +231,7 @@
`(;; Prefix tramp autosaves with "tramp-"
("\\`/[^/]*:\\([^/]*/\\)*\\([^/]*\\)\\'" ,(concat auto-save-list-file-prefix "tramp-\\2") t)
;; Local autosaves
(".*" ,auto-save-list-file-prefix t))
;; File name to use when saving desktop
desktop-base-file-name "emacs-session.el"
;; File name to use as a lock
desktop-base-lock-name (concat desktop-base-file-name ".lock")
;; Load only 5 buffers immediately, the remaining buffers will be loaded lazily
desktop-restore-eager 5
;; Avoid writing contents unchanged between auto-saves
desktop-file-checksum t

;; ====== Misc ======
;; Set `webjump' sites to manily search engins
webjump-sites
'(("Emacs Wiki" . [simple-query "www.emacswiki.org" "www.emacswiki.org/cgi-bin/wiki/" ""])
("DuckDuckGo" . [simple-query "duckduckgo.com" "duckduckgo.com/?q=" ""])
("Qwant" . [simple-query "www.qwant.com" "www.qwant.com/?q=" ""])
("Ecosia" . [simple-query "www.ecosia.org" "www.ecosia.org/search?q=" ""])
("Brave" . [simple-query "search.brave.com" "search.brave.com/search?q=" ""])
("Bing" . [simple-query "www.bing.com" "www.bing.com/search?q=" ""])
("Yahoo" . [simple-query "www.yahoo.com" "search.yahoo.com/search?p=" ""])
("Google" . [simple-query "www.google.com" "www.google.com/search?q=" ""])
("Google Maps" . [simple-query "www.google.com" "www.google.com/maps?q=" ""])
("Google Images" . [simple-query "www.google.com" "www.google.com/images?q=" ""])
("Google Groups" . [simple-query "groups.google.com" "groups.google.com/groups?q=" ""])
("StackOverflow" . [simple-query "stackoverflow.com" "stackoverflow.com/search?q=" ""])
("GitHub Repo" . [simple-query "github.com" "github.com/search?type=repositories&q=" ""])
("GitHub Code" . [simple-query "github.com" "github.com/search?type=code&q=" ""])
("WolframAlpha" . [simple-query "wolframalpha.com" "wolframalpha.com/input/?i=" ""])
("MDN" . [simple-query "developer.mozilla.org" "developer.mozilla.org/search?q=" ""])
("Youtube" . [simple-query "www.youtube.com" "www.youtube.com/results?search_query=" ""])
("Reddit" . [simple-query "www.reddit.com" "www.reddit.com/search/?q=" ""])
("Wikipedia" . [simple-query "wikipedia.org" "wikipedia.org/wiki/" ""])))
(".*" ,auto-save-list-file-prefix t)))

(setq-default
;; ====== Buffer-local variables ======
Expand All @@ -324,9 +246,7 @@
;; Display absolute line numbers in narrowed regions
display-line-numbers-widen t
;; Small tab is enough!
tab-width 2
;; Save buffer status
desktop-save-buffer t)
tab-width 2)

;; ====== Misc hooks and advices ======
;; Advice `emacs-session-filename' to ensure creating "session.ID" files in
Expand Down Expand Up @@ -360,24 +280,6 @@
(abort-recursive-edit))))

;; ====== Tweaks on file save ======
;; Update time stamp (if available) before saving a file.
(add-hook 'before-save-hook 'time-stamp)

(defcustom +whitespace-auto-cleanup-modes
'(prog-mode conf-mode org-mode markdown-mode
latex-mode tex-mode bibtex-mode)
"Enable auto white space cleanup before saving for these derived modes."
:group 'minemacs-edit
:type '(repeat symbol))

;; Auto-remove trailing white spaces before saving for modes defined in
;; `+whitespace-auto-cleanup-modes'.
(add-hook
'before-save-hook
(defun +save--whitespace-cleanup-h ()
(when (cl-some #'derived-mode-p +whitespace-auto-cleanup-modes)
(whitespace-cleanup))))

;; Guess the major mode after saving a file in `fundamental-mode' (adapted
;; from Doom Emacs).
(add-hook
Expand Down Expand Up @@ -454,9 +356,6 @@ or file path may exist now."
;; Replace selection after start typing
(delete-selection-mode 1)

;; Enable `recentf-mode' to remember recent files
(+shutup! (recentf-mode 1))

;; Show recursion depth in minibuffer (see `enable-recursive-minibuffers')
(minibuffer-depth-indicate-mode 1)

Expand All @@ -478,9 +377,6 @@ or file path may exist now."
;; Better handling for files with so long lines
(global-so-long-mode 1)

;; Save Emacs state from one session to another
(desktop-save-mode 1)

;; Global SubWord mode
(global-subword-mode 1))

Expand Down

0 comments on commit dcf61b7

Please sign in to comment.