From 2a73871d4051c9128e5df3d04d90ee1fce5af253 Mon Sep 17 00:00:00 2001 From: Ian Griffin Date: Fri, 22 Sep 2023 00:19:53 +0800 Subject: [PATCH] changed concating file and dirs into expand-file-name, and other minor improvements --- README.org | 4 ++++ gnus.el | 7 +++---- init.el | 2 +- init.org.d/10-misc.org | 8 ++++---- init.org.d/20-packages.org | 2 +- init.org.d/40-org.org | 2 +- init.org.d/50-ui.org | 21 +++++++++++++++++++-- init.org.d/60-ide.org | 16 ++++++++++++---- init.org.d/60-mail.org | 7 ++++--- init.org.d/70-lang.org | 25 ++++++++++++++++--------- init.org.d/80-misc-end.org | 2 +- todo.org | 3 ++- 12 files changed, 68 insertions(+), 31 deletions(-) diff --git a/README.org b/README.org index c19de43..b0a6176 100644 --- a/README.org +++ b/README.org @@ -9,6 +9,10 @@ This configuration works best on a GNU/Linux Platform, other platforms are untes Obviously, a full Emacs distribution needs to be installed. Other external dependencies is (usually) specified in their configuration. +*** Mail +For RMail to work, a mail syncer like mbsync needs to be installed. +And for emacs RMail to be able to read mbsync maildir format, GNU Mailutils is also needed to be installed + *** Language Servers For Language servers to work, the language servers needs to be installed separately, for example, in Fedora Linux, the required language servers can be installed by running the command below diff --git a/gnus.el b/gnus.el index 051344a..bfc94e8 100644 --- a/gnus.el +++ b/gnus.el @@ -22,8 +22,8 @@ ;; as the writer has no access to actual news servers, ;; and so gnus is used as a mail reader instead of UUCP news (require 'imap) -(setq gnus-select-method ` - (nnimap ,(cdr (assoc 'name main-mail-server)) +(setq gnus-select-method + `(nnimap ,(cdr (assoc 'name main-mail-server)) (nnimap-address ,(cdr (assoc 'imap-url main-mail-server))) (nnimap-server-port ,(cdr (assoc 'imap-port main-mail-server))) (nnimap-stream ,(cdr (assoc 'imap-stream main-mail-server))) @@ -31,8 +31,7 @@ gnus-secondary-select-methods `((nnmaildir "local" (directory - ,(concat (safe-getenv "HOME" user-home-dir-path) - "/.local/mails/disroot/"))))) + ,(expand-file-name ".local/mails/disroot/" (safe-getenv "HOME" user-home-path)))))) ;; ;; Demon diff --git a/init.el b/init.el index 35c4001..b88c78e 100644 --- a/init.el +++ b/init.el @@ -18,5 +18,5 @@ (let ((config-file-pattern "\\.org$")) (mapc #'org-babel-load-file (directory-files - (concat user-emacs-config-directory "/init.org.d") + (expand-file-name "init.org.d" user-emacs-config-directory) t config-file-pattern))) diff --git a/init.org.d/10-misc.org b/init.org.d/10-misc.org index bef9302..15e6994 100644 --- a/init.org.d/10-misc.org +++ b/init.org.d/10-misc.org @@ -13,21 +13,21 @@ Functions needed at the start of the configuration set the directory for emacs and it's apps to put stuff. #+begin_src emacs-lisp (setq user-emacs-directory - (concat (safe-getenv "XDG_DATA_HOME" "~/.local/share") "/emacs")) + (expand-file-name "emacs" (safe-getenv "XDG_DATA_HOME" "~/.local/share"))) #+end_src * Custom File This emacs feature is currently not used since a way to integrate this feature into this kind of configuration. #+begin_src emacs-lisp - (setq custom-file (concat user-emacs-directory "/custom.el")) + (setq custom-file (expand-file-name "custom.el" user-emacs-directory)) #+end_src * Personal File This file stores variables containing personal information, and is not distributed. A sample of this file though is included in this config to be used #+begin_src emacs-lisp - (let ((personal-file-path (concat user-emacs-config-directory "/personal.org")) - (sample-personal-file-path (concat user-emacs-config-directory "/personal-sample.org"))) + (let ((personal-file-path (expand-file-name "personal.org" user-emacs-config-directory)) + (sample-personal-file-path (expand-file-name "/personal-sample.org" user-emacs-config-directory ))) ;; load main personal file if it exists (if (file-exists-p personal-file-path) diff --git a/init.org.d/20-packages.org b/init.org.d/20-packages.org index bfe0b3f..40c404a 100644 --- a/init.org.d/20-packages.org +++ b/init.org.d/20-packages.org @@ -13,7 +13,7 @@ this speeds up emacs startup ** Set Package Directory #+begin_src emacs-lisp - (setq package-user-dir (concat (safe-getenv "XDG_DATA_HOME" "~/.local/share") "/emacs/packages")) + (setq package-user-dir (expand-file-name "emacs/packages" (safe-getenv "XDG_DATA_HOME" "~/.local/share"))) #+end_src ** Add package sources diff --git a/init.org.d/40-org.org b/init.org.d/40-org.org index ee55f21..ad3e23a 100644 --- a/init.org.d/40-org.org +++ b/init.org.d/40-org.org @@ -63,7 +63,7 @@ Make header and document title fonts bigger for better visibility. :custom (org-hide-emphasis-markers nil) (org-agenda-files - `(,(concat (safe-getenv "HOME" user-home-path) "/shared/org"))) + `(,(expand-file-name "shared/org" (safe-getenv "HOME" user-home-path)))) :config ;; font setup diff --git a/init.org.d/50-ui.org b/init.org.d/50-ui.org index 7d54225..a0c6791 100644 --- a/init.org.d/50-ui.org +++ b/init.org.d/50-ui.org @@ -8,7 +8,7 @@ this file/section configures the UI settings #+begin_src emacs-lisp (tool-bar-mode -1) (menu-bar-mode -1) - (scroll-bar-mode 1) + (scroll-bar-mode -1) #+end_src * Maximize @@ -19,7 +19,24 @@ this file/section configures the UI settings ;; (add-hook 'window-setup-hook 'toggle-frame-maximized t) #+END_SRC - + +* Window Size +Set the default window size when making a new frame +#+begin_src emacs-lisp + (defun set-window-size () + (add-to-list 'default-frame-alist '(width . 80)) + (add-to-list 'default-frame-alist '(height . 40)) + (add-to-list 'initial-frame-alist '(width . 80)) + (add-to-list 'initial-frame-alist '(height . 40))) +#+end_src + +run the function at startup of a frame +#+begin_src emacs-lisp + (when (display-graphic-p) + (set-window-size)) + (add-hook 'before-make-frame-hook 'set-window-size) +#+end_src + * Fringes Fringes are the small gap at the side of emacs. diff --git a/init.org.d/60-ide.org b/init.org.d/60-ide.org index d0b7459..ab30d7f 100644 --- a/init.org.d/60-ide.org +++ b/init.org.d/60-ide.org @@ -22,6 +22,13 @@ Tree-sitter Syntax Highlighting website]] :after tree-sitter) #+end_src +* Imenu-list +Imenu, the tool to get function names in source codes in emacs, displayed and constantly updated in a separate buffer +#+begin_src emacs-lisp + (use-package imenu-list + :commands (imenu-list-minor-mode)) +#+end_src + * Neotree Tree-based explorer for Emacs @@ -30,10 +37,11 @@ Tree-based explorer for Emacs :hook (neotree-mode . (lambda () (setq mode-line-format nil) (redraw-display))) - :config - (setq neo-theme 'arrows) - (setq neo-window-fixed-size nil) - (setq neo-smart-open t) + :custom + (neotheme 'arrows) + (neo-window-fixed-size t) + (neo-smart-open t) + (neo-window-width 22) :bind ("M-0" . neotree-toggle)) diff --git a/init.org.d/60-mail.org b/init.org.d/60-mail.org index 613fcd7..b783e58 100644 --- a/init.org.d/60-mail.org +++ b/init.org.d/60-mail.org @@ -22,7 +22,8 @@ machine smtp.example.com login jamie@example.com password verysecurepass port 58 * Gnus Config Tell gnus to read ~gnus.el~ from the config dir. #+begin_src emacs-lisp - (setq gnus-init-file (concat user-emacs-config-directory "/gnus.el")) + (setq gnus-init-file (expand-file-name "gnus.el" user-emacs-config-directory)) + ; (setq gnus-init-file "/home/iang/.config/emacs/gnus.el") #+end_src other configuration on gnus is on the ~gnus.el~ file. @@ -39,11 +40,11 @@ And those external programs are; ** Configuration #+begin_src emacs-lisp (setq rmail-primary-inbox-list - `( ,(concat "maildir://" (concat (safe-getenv "HOME" user-home-path) "/.local/mails/disroot/INBOX")) + `( ,(concat "maildir://" (expand-file-name ".local/mails/disroot/INBOX" (safe-getenv "HOME" user-home-path))) "/var/spool/mail/iang") rmail-preserve-inbox 1 rmail-mime-prefer-html nil - rmail-file-name (concat user-emacs-directory "/mails/inbox")) + rmail-file-name (expand-file-name "mails/inbox" user-emacs-directory)) #+end_src * SMTP Mail Config diff --git a/init.org.d/70-lang.org b/init.org.d/70-lang.org index f1e99e3..bd394ea 100644 --- a/init.org.d/70-lang.org +++ b/init.org.d/70-lang.org @@ -13,10 +13,7 @@ (company-mode)) #+end_src - * Built-in Modes - - ** hook default settings to configured language modes #+begin_src emacs-lisp (let ((langs '("sh" "c++" "mhtml" "java" "js" "python" "latex"))) @@ -26,12 +23,12 @@ ** add LSP server program names to eglot's configuration #+begin_src emacs-lisp - (let ((server-programs '((c++-mode . ("clangd")) - (mhtml-mode . ("html-language-server")) - (java-mode . ("jdtls")) - (js-mode . ("typescript-language-server")) - (python-mode . ("pyright")) - (latex-mode . ("texlab"))))) + (let ((server-programs '((c++-mode . ("clangd" "--stdio")) + (mhtml-mode . ("html-language-server" "--stdio")) + (java-mode . ("jdtls" "--stdio")) + (js-mode . ("typescript-language-server" "--stdio")) + (python-mode . ("pyright-langserver" "--stdio")) + (latex-mode . ("texlab" "--stdio"))))) (setq eglot-server-programs (append server-programs eglot-server-programs))) #+end_src @@ -67,3 +64,13 @@ :init (setq markdown-command "multimarkdown")) #+end_src + +** Python Pyenv +python venv manager + +#+begin_src emacs-lisp + (use-package pyvenv + :commands (pyvenv-mode pyvenv-activate pyvenv-workon pyvenv-exec-shell pyvenv-virtual-env) + :hook (python-mode . pyvenv-mode)) +#+end_src + diff --git a/init.org.d/80-misc-end.org b/init.org.d/80-misc-end.org index cd6b527..c30c5bd 100644 --- a/init.org.d/80-misc-end.org +++ b/init.org.d/80-misc-end.org @@ -121,7 +121,7 @@ Elfeed is a emacs package for reading RSS Web News. elfeed elfeed-update :custom - (elfeed-db-directory (concat user-emacs-directory "/elfeed") + (elfeed-db-directory (expand-file-name "elfeed" user-emacs-directory) "location for elfeed to put it's database") (elfeed-feeds '(("https://feeds.bbci.co.uk/news/technology/rss.xml" bbc technology) ("https://feeds.feedburner.com/rsscna/engnews" taiwan central focustaiwan) diff --git a/todo.org b/todo.org index f282b19..86d6f04 100644 --- a/todo.org +++ b/todo.org @@ -1,8 +1,9 @@ * Things to Improve in this configuration ** To Fix +- [ ] set chinese font - [X] stop using custom file - [X] separate font config - [X] add optimizations ==> dolist - [X] org-mode indentation ** Add -- [ ] use gnus +- [X] use gnus