Abderrahmane Faïz 3 周之前
当前提交
fc819febe1
共有 3 个文件被更改,包括 266 次插入0 次删除
  1. 112 0
      .emacs
  2. 32 0
      .emacs.custom.el
  3. 122 0
      .emacs.orgconf.el

+ 112 - 0
.emacs

@@ -0,0 +1,112 @@
+(add-to-list 'default-frame-alist '(width . 120))
+(add-to-list 'default-frame-alist '(height . 40))
+(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
+(package-initialize)
+(setq custom-file "~/.emacs.custom.el")
+(load-file custom-file)
+(load-file "~/.emacs.orgconf.el")
+
+;; fallback to this if dbus doesn't work
+;; (defun my/set-theme-based-on-time ()
+;;   (let ((hour (string-to-number (format-time-string "%H"))))
+;;     (if (or (< hour 7) (> hour 19) )
+;;         (load-theme 'modus-vivendi-tinted t)
+;;       (load-theme 'modus-operandi-tinted t))))
+;; (my/set-theme-based-on-time)
+;; (run-at-time "1 min" 3600 'my/set-theme-based-on-time)
+
+(require 'dbus)
+
+(defun my/system-dark-mode-p ()
+  "Return non-nil if GNOME prefers dark mode."
+  (string= 
+   (string-trim
+    (shell-command-to-string
+     "gsettings get org.gnome.desktop.interface color-scheme"))
+   "'prefer-dark'"))
+
+(defvar my/current-theme nil)
+
+(defun my/set-theme-based-on-system (&rest _)
+  "Load Emacs theme matching system appearance."
+  (let ((theme (if (my/system-dark-mode-p)
+                   'modus-vivendi-tinted
+                 'modus-operandi-tinted)))
+    (unless (eq theme my/current-theme)
+      (mapc #'disable-theme custom-enabled-themes)
+      (load-theme theme t)
+      (setq my/current-theme theme))))
+
+;; Apply theme at startup
+(my/set-theme-based-on-system)
+
+;; Update immediately when GNOME theme changes
+(dbus-register-signal
+ :session
+ "org.freedesktop.portal.Desktop"
+ "/org/freedesktop/portal/desktop"
+ "org.freedesktop.portal.Settings"
+ "SettingChanged"
+ #'my/set-theme-based-on-system)
+
+(add-hook 'prog-mode-hook #'display-line-numbers-mode)
+(add-hook 'prog-mode-hook #'completion-preview-mode)
+
+(setq completion-preview-minimum-symbol-length 2)
+(setq completion-preview-idle-delay 0.2)
+(setq column-number-mode t)
+
+(add-hook 'c-mode-hook #'eglot-ensure)
+(add-hook 'c++-mode-hook #'eglot-ensure)
+(add-hook 'rust-mode-hook #'eglot-ensure)
+
+(spacious-padding-mode 1)
+
+(use-package all-the-icons
+  :if (display-graphic-p))
+
+(use-package all-the-icons-dired
+  :hook (dired-mode . all-the-icons-dired-mode)
+  :config
+  (setq all-the-icons-dired-monochrome nil))
+
+(use-package doom-modeline
+  :init
+  (doom-modeline-mode 1))
+
+(use-package vertico
+  :init (vertico-mode))
+
+(use-package orderless
+  :custom
+  (completion-styles '(orderless basic)))
+
+(use-package marginalia
+  :init (marginalia-mode))
+
+(use-package consult)
+
+(global-set-key (kbd "C-x b") #'consult-buffer)
+(global-set-key (kbd "C-s") #'consult-line)
+
+(add-hook 'prog-mode-hook #'outline-minor-mode)
+
+;;(golden-ratio-mode 1)
+
+(add-hook 'org-mode-hook #'visual-line-mode)
+(add-hook 'org-mode-hook #'flyspell-mode)
+
+(move-text-default-bindings)
+
+;; Avoid performance issues in files with very long lines.
+(global-so-long-mode 1)
+
+(require 'multiple-cursors)
+(global-set-key (kbd "C-S-c C-S-c") 'mc/edit-lines)
+(global-set-key (kbd "C-§") 'mc/mark-next-like-this)
+(global-set-key (kbd "C-M-!") 'mc/mark-all-like-this)
+
+
+(global-set-key (kbd "C-d") 'duplicate-line)
+
+(put 'scroll-left 'disabled nil)

+ 32 - 0
.emacs.custom.el

@@ -0,0 +1,32 @@
+(custom-set-variables
+ ;; custom-set-variables was added by Custom.
+ ;; If you edit it by hand, you could mess it up, so be careful.
+ ;; Your init file should contain only one such instance.
+ ;; If there is more than one, they won't work right.
+ '(blink-cursor-mode nil)
+ '(eglot-autoshutdown nil)
+ '(electric-pair-mode t)
+ '(global-so-long-mode t)
+ '(inhibit-startup-screen t)
+ '(initial-major-mode 'org-mode)
+ '(initial-scratch-message "* SCRATCH BUFFER\n")
+ '(load-prefer-newer t)
+ '(menu-bar-mode nil)
+ '(org-startup-folded 'content)
+ '(org-startup-indented t)
+ '(package-selected-packages
+   '(all-the-icons all-the-icons-dired consult doom-modeline emmet-mode
+		   expand-region golden-ratio magit marginalia
+		   markdown-mode move-text multiple-cursors
+		   ocaml-eglot orderless rust-mode spacious-padding
+		   tuareg vertico wcheck-mode web-mode))
+ '(read-quoted-char-radix 16)
+ '(scroll-bar-mode nil)
+ '(so-long-threshold 1000)
+ '(tool-bar-mode nil))
+(custom-set-faces
+ ;; custom-set-faces was added by Custom.
+ ;; If you edit it by hand, you could mess it up, so be careful.
+ ;; Your init file should contain only one such instance.
+ ;; If there is more than one, they won't work right.
+ '(default ((t (:inherit nil :extend nil :stipple nil :inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant normal :weight regular :height 100 :width normal :foundry "JetBrains  " :family "JetBrains Mono")))))

+ 122 - 0
.emacs.orgconf.el

@@ -0,0 +1,122 @@
+(setq org-agenda-files '("~/org/capture.org" "~/org/main.org"))
+(setq org-agenda-include-diary t)
+(setq org-capture-templates
+      '(("G" "Define a goal" entry
+	 (file+headline "~/org/capture.org" "Capture")
+	 (file "~/org/tpl/tpl_goal.txt") :empty-lines-after 2)
+	("N" "NEXT entry" entry
+	 (file+headline "~/org/capture.org" "Capture")
+	 (file "~/org/tpl/tpl_next.txt") :empty-lines-before 1)
+	("T" "TODO entry" entry
+	 (file+headline "~/org/capture.org" "Capture")
+	 (file "~/org/tpl/tpl_todo.txt") :empty-lines-before 1)
+	("W" "WAITING entry" entry
+	 (file+headline "~/org/capture.org" "Capture")
+	 (file "~/org/tpl/tpl_waiting.txt") :empty-lines-before 1)
+	("S" "SOMEDAY entry" entry
+	 (file+headline "~/org/capture.org" "Capture")
+	 (file "~/org/tpl/tpl_someday.txt") :empty-lines-before 1)
+	("P" "PROJ entry" entry
+	 (file+headline "~/org/capture.org" "Capture")
+	 (file "~/org/tpl/tpl_proj.txt") :empty-lines-before 1)
+	("B" "Book on the to-read-list" entry
+	 (file+headline "~/org/main.org" "Books to read")
+	 (file "~/org/tpl/tpl_book.txt") :empty-lines-after 2)
+	("D" "Add a daily plan checklist" entry
+	 (file+olp+datetree "~/org/daily_plan.org")
+	 (file "~/org/tpl/tpl_daily_plan.txt"))
+	("n" "Note" entry
+	 (file+headline "~/org/notes.org" "Random Notes") "** %?"
+	 :empty-lines 0)
+	("J" "Add a journal entry" entry
+	 (file+olp+datetree "~/org/journal.org")
+	 "* %<%H:%M> - %^{Activity}\12%?")
+	("w" "Add 10 I wants" entry
+	 (file+olp+datetree "~/org/wants.org") "* %<%H:%M>\0121. %?")
+	("b" "Add an item to buy" entry
+	 (file+headline "~/org/main.org" "Wish List")
+	 (file "~/org/tpl/tpl_wishlist.txt") :empty-lines-before 1)))
+(setq org-clock-into-drawer "CLOCKING")
+(setq org-enforce-todo-checkbox-dependencies t)
+(setq org-enforce-todo-dependencies t)
+(setq org-hide-emphasis-markers t)
+(setq org-hide-leading-stars t)
+(setq org-log-into-drawer t)
+(setq org-log-repeat nil)
+(setq org-log-reschedule 'note)
+(setq org-modules
+      '(ol-bbdb ol-bibtex ol-docview ol-doi ol-eww ol-gnus org-habit ol-info
+		ol-irc ol-mhe ol-rmail ol-w3m))
+(setq org-refile-allow-creating-parent-nodes 'confirm)
+(setq org-refile-targets '((org-agenda-files :maxlevel . 2)))
+(setq org-startup-folded 'content)
+(setq org-startup-indented t)
+
+
+
+(defun my/copy-idlink-to-clipboard() "Copy an ID link with the
+headline to killring, if no ID is there then create a new unique
+ID.  This function works only in org-mode or org-agenda buffers. 
+
+The purpose of this function is to easily construct id:-links to 
+org-mode items. If its assigned to a key it saves you marking the
+text and copying to the killring."
+       (interactive)
+       (when (eq major-mode 'org-agenda-mode) ;if we are in agenda mode we switch to orgmode
+	 (org-agenda-show)
+	 (org-agenda-goto))       
+       (when (eq major-mode 'org-mode) ; do this only in org-mode buffers
+	 (setq mytmphead (nth 4 (org-heading-components)))
+         (setq mytmpid (funcall 'org-id-get-create))
+	 (setq mytmplink (format "[[id:%s][%s]]" mytmpid mytmphead))
+	 (kill-new mytmplink)
+	 (message "Copied %s to killring (clipboard)" mytmplink)
+	 ))
+
+(global-set-key (kbd "<f5>") 'my/copy-idlink-to-clipboard)
+
+(defun org-reset-checkbox-state-maybe ()
+  "Reset all checkboxes in an entry if the `RESET_CHECK_BOXES' property is set"
+  (interactive "*")
+  (if (org-entry-get (point) "RESET_CHECK_BOXES")
+      (org-reset-checkbox-state-subtree)))
+
+(defun org-checklist ()
+  (when (member org-state org-done-keywords) ;; org-state dynamically bound in org.el/org-todo
+    (org-reset-checkbox-state-maybe)))
+
+(add-hook 'org-after-todo-state-change-hook 'org-checklist)
+
+(setq org-todo-keywords
+      '((sequence "REPEAT(r)" "NEXT(n@/!)" "TODO(t@/!)" "WAITING(w@/!)" "SOMEDAY(s@/!)" "PROJ(p)" "|" "DONE(d@)" "CANCELLED(c@)")
+	(sequence "GOAL(g)" "|" "ACHIEVED(a@)" "MISSED(m@)")
+	))
+
+;; TODO colors
+(setq org-todo-keyword-faces
+      '(
+        ("TODO" . (:foreground "GoldenRod" :weight bold))
+        ("NEXT" . (:foreground "DeepPink" :weight bold))
+        ("WAITING" . (:foreground "dim gray" :weight bold))
+        ("REPEAT" . (:foreground "DarkOrange" :weight bold))
+        ("PROJ" . (:foreground "Red" :weight bold))
+        ("SOMEDAY" . (:foreground "chocolate" :weight bold))
+        ("DONE" . (:foreground "LimeGreen" :weight bold))
+        ("CANCELLED" . (:foreground "LimeGreen" :weight bold))
+	("GOAL" . (:foreground "deep sky blue" :weight bold))
+	("ACHIEVED" . (:foreground "green" :weight bold))
+	("MISSED" . (:foreground "saddle brown" :weight bold))
+        ))
+
+;;org Tags
+(setq org-tag-alist '(("BOOK" . ?b)))
+;; Tag colors
+(setq org-tag-faces
+      '(
+        ("BOOK"  . (:foreground "mediumPurple1" :weight bold))
+        ("NEW"   . (:foreground "royalblue1"    :weight bold))
+        )
+      )
+
+(global-set-key (kbd "C-c a") 'org-agenda)
+(global-set-key (kbd "<f6>") 'org-capture)