From ea1e815c3dc1781aa5cb6d401e233c73fa8a108b Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Mon, 26 Jun 2023 15:17:20 +1000 Subject: Adapted more configs from other emacs configs Including wasamasa and jwiegley --- emacs/.emacs.d/early-init.el | 3 --- emacs/.emacs.d/init/ycp-basic.el | 8 ++++-- emacs/.emacs.d/init/ycp-buffer.el | 2 -- emacs/.emacs.d/init/ycp-complete.el | 9 ++++--- emacs/.emacs.d/init/ycp-dired.el | 2 -- emacs/.emacs.d/init/ycp-editing.el | 25 ++++++++++++------ emacs/.emacs.d/init/ycp-gnus.el | 2 -- emacs/.emacs.d/init/ycp-grep.el | 32 +++++++++++------------ emacs/.emacs.d/init/ycp-help.el | 5 ++-- emacs/.emacs.d/init/ycp-org.el | 11 +++++--- emacs/.emacs.d/init/ycp-pdf.el | 7 +++-- emacs/.emacs.d/init/ycp-prog.el | 49 +++++++++++++++++++++++++++++++---- emacs/.emacs.d/init/ycp-project.el | 1 + emacs/.emacs.d/init/ycp-system.el | 19 +++++++++++--- emacs/.emacs.d/init/ycp-time.el | 2 -- emacs/.emacs.d/init/ycp-vc.el | 16 +++++++++--- emacs/.emacs.d/lisp/my/my-buffer.el | 2 -- emacs/.emacs.d/lisp/my/my-corfu.el | 2 -- emacs/.emacs.d/lisp/my/my-editing.el | 22 +++++++++++++--- emacs/.emacs.d/lisp/my/my-hnreader.el | 2 -- emacs/.emacs.d/lisp/my/my-org.el | 19 ++++++++++++-- emacs/.emacs.d/lisp/my/my-package.el | 7 +++-- emacs/.emacs.d/lisp/my/my-prog.el | 39 ++++++++++++++++++++++++---- emacs/.emacs.d/lisp/my/my-project.el | 45 ++++++++++++++++++++++++++++++++ emacs/.emacs.d/lisp/my/my-system.el | 36 +++++++++++++++++++++++++ emacs/.emacs.d/lisp/my/my-utils.el | 5 ++++ misc/.config/zathura/zathurarc | 2 ++ 27 files changed, 295 insertions(+), 79 deletions(-) create mode 100644 emacs/.emacs.d/lisp/my/my-system.el create mode 100644 misc/.config/zathura/zathurarc diff --git a/emacs/.emacs.d/early-init.el b/emacs/.emacs.d/early-init.el index 59c9a84..abe008e 100644 --- a/emacs/.emacs.d/early-init.el +++ b/emacs/.emacs.d/early-init.el @@ -3,9 +3,6 @@ ;; Copyright (C) 2023 Free Software Foundation. ;; Author: Yuchen Pei -;; Protesilaos Stavrou -;; John Wiegley -;; Maintainer: Yuchen Pei ;; Package-Requires: ((emacs "28.2")) ;; This file is part of dotfiles. diff --git a/emacs/.emacs.d/init/ycp-basic.el b/emacs/.emacs.d/init/ycp-basic.el index 12000e5..160c385 100644 --- a/emacs/.emacs.d/init/ycp-basic.el +++ b/emacs/.emacs.d/init/ycp-basic.el @@ -3,8 +3,6 @@ ;; Copyright (C) 2023 Free Software Foundation. ;; Author: Yuchen Pei -;; Protesilaos Stavrou -;; Maintainer: Yuchen Pei ;; Package-Requires: ((emacs "28.2")) ;; This file is part of dotfiles. @@ -36,8 +34,11 @@ "C-x C-c C-c" #'save-buffers-kill-emacs "C-x C-z" nil ) + (my-keybind special-event-map + "" 'my-quit-emacs) (setq auth-source-save-behavior nil) (setq use-short-answers t) + (setq use-dialog-box nil) (prefer-coding-system 'utf-8) (set-default-coding-systems 'utf-8) (set-terminal-coding-system 'utf-8) @@ -45,6 +46,9 @@ (set-language-environment 'utf-8) (setq load-prefer-newer t) (setq message-log-max 16384) + (setq attempt-stack-overflow-recovery nil) + (setq confirm-kill-processes nil) + (setq attempt-orderly-shutdown-on-fatal-signal nil) ) (my-configure diff --git a/emacs/.emacs.d/init/ycp-buffer.el b/emacs/.emacs.d/init/ycp-buffer.el index 91edec5..3c9f339 100644 --- a/emacs/.emacs.d/init/ycp-buffer.el +++ b/emacs/.emacs.d/init/ycp-buffer.el @@ -3,8 +3,6 @@ ;; Copyright (C) 2023 Free Software Foundation. ;; Author: Yuchen Pei -;; Protesilaos Stavrou -;; Maintainer: Yuchen Pei ;; Package-Requires: ((emacs "28.2")) ;; This file is part of dotfiles. diff --git a/emacs/.emacs.d/init/ycp-complete.el b/emacs/.emacs.d/init/ycp-complete.el index 8e27f8e..c29b4d2 100644 --- a/emacs/.emacs.d/init/ycp-complete.el +++ b/emacs/.emacs.d/init/ycp-complete.el @@ -3,8 +3,6 @@ ;; Copyright (C) 2023 Free Software Foundation. ;; Author: Yuchen Pei -;; Protesilaos Stavrou -;; Maintainer: Yuchen Pei ;; Package-Requires: ((emacs "28.2")) ;; This file is part of dotfiles. @@ -165,7 +163,12 @@ (my-package company (:install t) (:delay 5) - (add-hook 'message-mode-hook #'company-mode)) + (add-hook 'message-mode-hook #'company-mode) + (setq company-idle-delay .1 + company-minimum-prefix-length 2 + company-selection-wrap-around t + company-show-numbers t + company-require-match 'never)) ;;; cape (my-package cape diff --git a/emacs/.emacs.d/init/ycp-dired.el b/emacs/.emacs.d/init/ycp-dired.el index 613bc0b..a0892ab 100644 --- a/emacs/.emacs.d/init/ycp-dired.el +++ b/emacs/.emacs.d/init/ycp-dired.el @@ -3,8 +3,6 @@ ;; Copyright (C) 2023 Free Software Foundation. ;; Author: Yuchen Pei -;; Protesilaos Stavrou -;; Maintainer: Yuchen Pei ;; Package-Requires: ((emacs "28.2")) ;; This file is part of dotfiles. diff --git a/emacs/.emacs.d/init/ycp-editing.el b/emacs/.emacs.d/init/ycp-editing.el index ab1bc9e..7af3587 100644 --- a/emacs/.emacs.d/init/ycp-editing.el +++ b/emacs/.emacs.d/init/ycp-editing.el @@ -3,8 +3,6 @@ ;; Copyright (C) 2023 Free Software Foundation. ;; Author: Yuchen Pei -;; Protesilaos Stavrou -;; Maintainer: Yuchen Pei ;; Package-Requires: ((emacs "28.2")) ;; This file is part of dotfiles. @@ -40,13 +38,15 @@ (setq show-paren-delay 0) (setq window-divider-default-bottom-width 1) (setq window-divider-default-places 'bottom-only) -(define-key input-decode-map [?\C-m] [C-m]) ; don't interpret C-m as RET +;; don't interpret C-m as RET +(define-key input-decode-map [?\C-m] [C-m]) +(setq save-place-file (locate-user-emacs-file "saveplace")) (my-package my-editing (:delay 5) (my-keybind global-map - "C-k" #'my-kill-forward - "M-k" #'my-kill-backward + "C-k" #'my-kill-line + "M-k" #'my-kill-line-backward "M-w" #'my-copy-line-or-region "C-o" #'my-new-line-above-or-below "C-<" #'my-escape-url-dwim @@ -66,9 +66,9 @@ "C-M-y" #'my-yank-primary "C-a" #'my-beginning-of-line-or-indentation "M-c" #'my-copy-buffer-file-name ; override capitalize - "M-o" #'delete-blank-lines ; alias for C-x C-o + "M-o" #'delete-blank-lines ; alias for C-x C-o "M-SPC" #'cycle-spacing - "M-z" #'zap-up-to-char ; NOT `zap-to-char' + "M-z" #'zap-up-to-char ; NOT `zap-to-char' "" #'backward-kill-sexp ) (electric-pair-mode) @@ -118,7 +118,10 @@ (define-key global-map (kbd "C-x F") 'my-sudo-find-file) ;; find file -(ffap-bindings) +(my-package ffap + (ffap-bindings) + ;; Stop ffap from pinging things that look like domain names + (setq ffap-machine-p-known 'accept)) (put 'narrow-to-region 'disabled nil) @@ -128,8 +131,14 @@ (setq version-control t) (add-hook 'text-mode-hook #'turn-on-auto-fill) + +(my-add-hooks #'my-non-special-modes-setup '(text-mode prog-mode)) + (add-to-list 'auto-mode-alist '("\\(README\\|CHANGELOG\\|COPYING\\|LICENSE\\)\\'" . text-mode)) (add-hook 'before-save-hook 'time-stamp) + +(save-place-mode 1) + (provide 'ycp-editing) diff --git a/emacs/.emacs.d/init/ycp-gnus.el b/emacs/.emacs.d/init/ycp-gnus.el index d8ae4ed..f061fcf 100644 --- a/emacs/.emacs.d/init/ycp-gnus.el +++ b/emacs/.emacs.d/init/ycp-gnus.el @@ -3,8 +3,6 @@ ;; Copyright (C) 2023 Free Software Foundation. ;; Author: Yuchen Pei -;; Protesilaos Stavrou -;; Maintainer: Yuchen Pei ;; Package-Requires: ((emacs "28.2")) ;; This file is part of dotfiles. diff --git a/emacs/.emacs.d/init/ycp-grep.el b/emacs/.emacs.d/init/ycp-grep.el index 3c784f0..2e75e26 100644 --- a/emacs/.emacs.d/init/ycp-grep.el +++ b/emacs/.emacs.d/init/ycp-grep.el @@ -3,8 +3,6 @@ ;; Copyright (C) 2023 Free Software Foundation. ;; Author: Yuchen Pei -;; Protesilaos Stavrou -;; Maintainer: Yuchen Pei ;; Package-Requires: ((emacs "28.2")) ;; This file is part of dotfiles. @@ -40,24 +38,24 @@ (grep-apply-setting 'grep-find-template "find -H -type f -exec grep -n --null -E -A1 -B1 /dev/null \\{\\} +") (setq grep-files-aliases - '(("all" . "* .*") - ("el" . "*.el") - ("ch" . "*.[ch]") - ("c" . "*.c") - ("cc" . "*.cc *.cxx *.cpp *.C *.CC *.c++") - ("cchh" . "*.cc *.[ch]xx *.[ch]pp *.[CHh] *.CC *.HH *.[ch]++") - ("hh" . "*.hxx *.hpp *.[Hh] *.HH *.h++") - ("h" . "*.h") - ("l" . "[Cc]hange[Ll]og*") - ("m" . "[Mm]akefile*") - ("tex" . "*.tex") - ("texi" . "*.texi") - ("asm" . "*.[sS]") - ("docs" . "*.md *.html *.rst *.org *.txt *.asciidoc *.adoc *.tex *.texi"))) + '(("all" . "* .*") + ("el" . "*.el") + ("ch" . "*.[ch]") + ("c" . "*.c") + ("cc" . "*.cc *.cxx *.cpp *.C *.CC *.c++") + ("cchh" . "*.cc *.[ch]xx *.[ch]pp *.[CHh] *.CC *.HH *.[ch]++") + ("hh" . "*.hxx *.hpp *.[Hh] *.HH *.h++") + ("h" . "*.h") + ("l" . "[Cc]hange[Ll]og*") + ("m" . "[Mm]akefile*") + ("tex" . "*.tex") + ("texi" . "*.texi") + ("asm" . "*.[sS]") + ("docs" . "*.md *.html *.rst *.org *.txt *.asciidoc *.adoc *.tex *.texi"))) (my-keybind global-map "C-c r f" #'grep-find "C-c r g" #'grep) -) + ) (my-package my-grep (:delay 10) diff --git a/emacs/.emacs.d/init/ycp-help.el b/emacs/.emacs.d/init/ycp-help.el index b699be9..9ed0831 100644 --- a/emacs/.emacs.d/init/ycp-help.el +++ b/emacs/.emacs.d/init/ycp-help.el @@ -3,8 +3,6 @@ ;; Copyright (C) 2023 Free Software Foundation. ;; Author: Yuchen Pei -;; Protesilaos Stavrou -;; Maintainer: Yuchen Pei ;; Package-Requires: ((emacs "28.2")) ;; This file is part of dotfiles. @@ -56,7 +54,8 @@ (my-package eldoc (:delay 5) - (setq eldoc-echo-area-prefer-doc-buffer t) + (setq eldoc-echo-area-prefer-doc-buffer t + eldoc-idle-delay .1) ) (my-package man diff --git a/emacs/.emacs.d/init/ycp-org.el b/emacs/.emacs.d/init/ycp-org.el index 77c4436..a5917a6 100644 --- a/emacs/.emacs.d/init/ycp-org.el +++ b/emacs/.emacs.d/init/ycp-org.el @@ -35,6 +35,8 @@ "C-c a" #'org-agenda "C-c c" #'org-capture "" #'my-org-open-default-notes-file + "C-a" #'my-org-beginning-of-line-or-indent + "C-k" #'my-org-kill-line ) (setq org-startup-folded 'overview) (my-override org-next-link) @@ -50,7 +52,7 @@ (my-keybind org-mode-map "C-j" #'org-return-and-maybe-indent) (my-keybind org-mode-map - "C-j" #'default-indent-new-line)) + "C-j" #'default-indent-new-line)) (my-keybind minibuffer-mode-map "M-l" #'org-insert-last-stored-link) (my-setq-from-local my-org-common-properties org-directory my-org-doc-dir) @@ -66,12 +68,14 @@ (setq org-special-ctrl-a/e t) (setq org-special-ctrl-k t) (setq org-M-RET-may-split-line '((default . t))) - (setq org-catch-invisible-edits 'show) + (setq org-catch-invisible-edits 'error) (setq org-modules '(ol-bbdb ol-gnus ol-info)) (setq org-use-sub-superscripts '{}) (setq org-todo-keywords '((sequence "TODO(t!)" "DOIN(i!)" "WAIT(w!)" "|" "DONE(d!)" "OBSO(o!)" "DUPL(u!)"))) + (setq org-enforce-todo-dependencies t + org-enforce-todo-checkbox-dependencies t) (setq org-use-fast-todo-selection 'expert) (setq org-fontify-quote-and-verse-blocks t) (setq org-highlight-latex-and-related nil) ; other options affect elisp regexp @@ -99,7 +103,8 @@ ("v" . "verse"))) (setq org-use-tag-inheritance nil) (my-setq-from-local org-default-notes-file) - (setq org-export-backends '(ascii beamer html icalendar latex md odt org)) + (setq org-export-backends '(ascii beamer html latex md odt org)) + (setq org-export-with-sub-superscripts '{}) (setq org-image-actual-width '(400)) (setq org-log-into-drawer t) (plist-put org-format-latex-options :scale 1.5) diff --git a/emacs/.emacs.d/init/ycp-pdf.el b/emacs/.emacs.d/init/ycp-pdf.el index d90a527..4be7a68 100644 --- a/emacs/.emacs.d/init/ycp-pdf.el +++ b/emacs/.emacs.d/init/ycp-pdf.el @@ -31,7 +31,9 @@ (my-package pdf-tools (:install t) (:delay 15) - (pdf-loader-install)) + (pdf-loader-install) + (my-keybind pdf-view-mode-map + "M-w" #'pdf-view-kill-ring-save)) (my-package pdf-history (:delay 15) @@ -52,7 +54,8 @@ "P" #'my-pdf-view-backward-node-same-depth "U" #'my-pdf-view-backward-node-lower-depth "." #'my-pdf-view-enlarge-a-bit - "," #'my-pdf-view-shrink-a-bit) + "," #'my-pdf-view-shrink-a-bit + ) ) (provide 'ycp-pdf) diff --git a/emacs/.emacs.d/init/ycp-prog.el b/emacs/.emacs.d/init/ycp-prog.el index 6392cf8..0b04509 100644 --- a/emacs/.emacs.d/init/ycp-prog.el +++ b/emacs/.emacs.d/init/ycp-prog.el @@ -115,7 +115,7 @@ #'my-comint-send-input-and-return-prompt) (add-to-list 'my-buffer-create-functions '(shell-mode . my-shell-with-directory)) - (my-keybind shell-mode-map "" #'my-restart-shell) + (my-keybind comint-mode-map "" #'my-comint-restart) (add-hook 'shell-mode-hook 'my-shell-disable-company-if-remote) (my-keybind global-map "" #'my-switch-or-create-shell-buffer) ) @@ -134,10 +134,8 @@ ;; (bash-completion-setup) ) -;;; prog modes: c, c++, elisp, js, css, ts, (my-package prog-mode - (add-hook 'prog-mode-hook #'display-line-numbers-mode) - (add-hook 'prog-mode-hook (lambda () (setq-local tab-width 2)))) + (add-hook 'prog-mode-hook #'my-prog-modes-setup)) ;; cmake (my-package cmake-mode @@ -183,6 +181,15 @@ (define-key c-mode-map (kbd "C-c C-c") 'compile) (define-key c++-mode-map (kbd "C-c C-c") 'project-compile) (add-to-list 'auto-mode-alist '("\\.inl\\'" . c++-mode)) + (setq c-default-style + '((java-mode . "java") + (awk-mode . "awk") + (c-mode . "user") + (c++-mode . "user") + (other . "gnu"))) + (setq-default c-electric-flag t) + ;; prevent backspace from untabifying + (setq c-backspace-function 'delete-backward-char) ) (my-package my-prog @@ -199,7 +206,9 @@ (my-package elisp-mode (:delay 10) (my-keybind emacs-lisp-mode-map - "C-c C-c" #'eval-buffer) + "C-c C-c" #'eval-buffer + "C-c C-z" #'ielm + "C-," #'my-insert-current-prefix) (add-hook 'emacs-lisp-mode-hook (lambda () (auto-fill-mode 1))) (setq print-length 1000) (my-keybind global-map @@ -215,11 +224,20 @@ 'emacs-lisp-mode))) ;; for deep recursion, e.g. in radix tree (setq max-specpdl-size 32000) + (add-to-list 'auto-mode-alist '("Cask\\'" . emacs-lisp-mode)) (require 'my-prog) (my-keybind emacs-lisp-mode-map "C-M-x" #'my-eval-defun-or-region) ) +(my-package data-debug + (:delay 10) + (my-keybind global-map + "C-:" 'data-debug-eval-expression)) + +(setq debugger-stack-frame-as-list t) +(setq display-raw-bytes-as-hex t) + ;;; paredit (my-package paredit (:install t) @@ -243,6 +261,15 @@ "M-h" #'paredit-convolute-sexp) ) +(my-package compile + (:delay 15) + (setq compilation-always-kill t + compilation-ask-about-save nil + compilation-context-lines 10 + compilation-scroll-output 'first-error + compilation-skip-threshold 2) + ) + ;;; flymake (my-package flymake (:install t) @@ -468,5 +495,17 @@ (add-hook 'c++-mode-hook 'my-set-header-line-to-which-func) ) +;;; nxml +(my-package nxml-mode + (:delay 60) + (setq nxml-slash-auto-complete-flag t)) + +(my-package etags + (:delay 60) + (setq tags-file-name "TAGS")) + +(my-package nroff-mode + (add-to-list 'auto-mode-alist '("\\.mdoc\\'" . nroff-mode))) + (provide 'ycp-prog) ;;; ycp-prog.el ends here diff --git a/emacs/.emacs.d/init/ycp-project.el b/emacs/.emacs.d/init/ycp-project.el index e5442bb..15c7fcc 100644 --- a/emacs/.emacs.d/init/ycp-project.el +++ b/emacs/.emacs.d/init/ycp-project.el @@ -36,6 +36,7 @@ "\C-xpD" #'my-project-dired-at "\C-xpR" #'my-project-rgrep-at "\C-xpC" #'my-project-code-stats) + (my-override project-remember-projects-under) (my-server-idle-timer my-project-remember-projects-timer 300 t diff --git a/emacs/.emacs.d/init/ycp-system.el b/emacs/.emacs.d/init/ycp-system.el index 3d52d34..6dbcf7d 100644 --- a/emacs/.emacs.d/init/ycp-system.el +++ b/emacs/.emacs.d/init/ycp-system.el @@ -3,8 +3,6 @@ ;; Copyright (C) 2023 Free Software Foundation. ;; Author: Yuchen Pei -;; Protesilaos Stavrou -;; Maintainer: Yuchen Pei ;; Package-Requires: ((emacs "28.2")) ;; This file is part of dotfiles. @@ -45,7 +43,18 @@ (setq tramp-default-method "ssh") (setq explicit-shell-file-name "/bin/bash") (add-to-list 'tramp-remote-path 'tramp-own-remote-path) - + ;; keep backup files locally rather than remote + (setq tramp-backup-directory-alist backup-directory-alist) + (with-eval-after-load 'tramp-cache + (setq tramp-persistency-file-name (locate-user-emacs-file + "tramp"))) + ;; Use discovered value for ssh options + (setq tramp-ssh-controlmaster-options "") + ;; Stop tramp from interfering with everything + (setq file-name-handler-alist + (seq-filter + (--remove (string-match-p "^tramp" (symbol-name (cdr it))) + file-name-handler-alist))) (connection-local-set-profile-variables 'termux-bash '((explicit-shell-file-name . "/data/data/com.termux/files/usr/bin/bash") @@ -79,7 +88,9 @@ '((explicit-shell-file-name . "/system/bin/sh"))) (connection-local-set-profiles '(:application tramp :protocol "adb") - 'adb-shell)) + 'adb-shell) + (require 'my-system) + (setq file-name-handler-alist (my-file-handlers-without-tramp))) (provide 'ycp-system) ;;; ycp-system.el ends here diff --git a/emacs/.emacs.d/init/ycp-time.el b/emacs/.emacs.d/init/ycp-time.el index bc43764..f98a9cd 100644 --- a/emacs/.emacs.d/init/ycp-time.el +++ b/emacs/.emacs.d/init/ycp-time.el @@ -3,8 +3,6 @@ ;; Copyright (C) 2023 Free Software Foundation. ;; Author: Yuchen Pei -;; Protesilaos Stavrou -;; Maintainer: Yuchen Pei ;; Package-Requires: ((emacs "28.2")) ;; This file is part of dotfiles. diff --git a/emacs/.emacs.d/init/ycp-vc.el b/emacs/.emacs.d/init/ycp-vc.el index d9de2ca..66bb06f 100644 --- a/emacs/.emacs.d/init/ycp-vc.el +++ b/emacs/.emacs.d/init/ycp-vc.el @@ -52,7 +52,6 @@ (setq ediff-make-buffers-readonly-at-startup nil) (setq ediff-show-clashes-only t) (setq ediff-split-window-function 'split-window-horizontally) - (setq ediff-window-setup-function 'ediff-setup-windows-plain) ) (my-package vc-git @@ -61,6 +60,17 @@ '(vc-git-annotate-switches . "-w")) (setq vc-git-grep-template "git --no-pager grep -n -A1 -B1 -e -- ")) +(my-package diff-hl + (:delay 30) + (:install t) + (global-diff-hl-mode) + (diff-hl-flydiff-mode)) + +(my-package diffview + (:delay 30) + (:install t) + ) + (my-package git-commit (:install t) (:delay 30) @@ -78,14 +88,14 @@ (require 'magit-repos) (my-setq-from-local magit-repository-directories) (put 'magit-clean 'disabled nil) -) + ) (my-package my-magit (:delay 30) (my-keybind global-map "C-x pM" #'my-project-magit-at "C-x g" #'my-magit-status) -) + ) (my-package magit-annex (:delay 60)) diff --git a/emacs/.emacs.d/lisp/my/my-buffer.el b/emacs/.emacs.d/lisp/my/my-buffer.el index 9c7da4a..abe007f 100644 --- a/emacs/.emacs.d/lisp/my/my-buffer.el +++ b/emacs/.emacs.d/lisp/my/my-buffer.el @@ -3,8 +3,6 @@ ;; Copyright (C) 2023 Free Software Foundation. ;; Author: Yuchen Pei -;; Protesilaos Stavrou -;; Maintainer: Yuchen Pei ;; Package-Requires: ((emacs "28.2")) ;; This file is part of dotfiles. diff --git a/emacs/.emacs.d/lisp/my/my-corfu.el b/emacs/.emacs.d/lisp/my/my-corfu.el index 191f513..2d1ba27 100644 --- a/emacs/.emacs.d/lisp/my/my-corfu.el +++ b/emacs/.emacs.d/lisp/my/my-corfu.el @@ -3,8 +3,6 @@ ;; Copyright (C) 2023 Free Software Foundation. ;; Author: Yuchen Pei -;; Protesilaos Stavrou -;; Maintainer: Yuchen Pei ;; Package-Requires: ((emacs "28.2")) ;; This file is part of dotfiles. diff --git a/emacs/.emacs.d/lisp/my/my-editing.el b/emacs/.emacs.d/lisp/my/my-editing.el index 47e33a3..940a338 100644 --- a/emacs/.emacs.d/lisp/my/my-editing.el +++ b/emacs/.emacs.d/lisp/my/my-editing.el @@ -3,9 +3,6 @@ ;; Copyright (C) 2023 Free Software Foundation. ;; Author: Yuchen Pei -;; Protesilaos Stavrou -;; Stefan Monnier -;; Maintainer: Yuchen Pei ;; Package-Requires: ((emacs "28.2")) ;; This file is part of dotfiles. @@ -336,6 +333,13 @@ Basically move the line up (goto-line line) (forward-char col))) +(defun my-kill-line (&optional arg) + "Calls `my-kill-forward' or `kill-line' in case of prefix arg." + (interactive "P") + (if prefix-arg + (kill-line) + (my-kill-forward))) + (defun my-kill-forward () "Kill towards end of line, but not out of sexp." (interactive) @@ -354,6 +358,13 @@ Basically move the line up (setq end (point))) (kill-region (point) end)))) +(defun my-kill-line-backward (&optional arg) + "Calls `my-kill-backward' or `kill-line' with 0 in case of prefix arg." + (interactive "P") + (if prefix-arg + (kill-line 0) + (my-kill-backward))) + (defun my-kill-backward () "Kill towards beginning of line, but not out of sexp." (interactive) @@ -385,5 +396,10 @@ With an prefix-arg, copy the file name relative to project root." (kill-new to-kill) (message "Copied %s" to-kill))) +(defun my-non-special-modes-setup () + (setq indicate-empty-lines t) + (setq show-trailing-whitespace t) + ) + (provide 'my-editing) ;;; my-editing.el ends here diff --git a/emacs/.emacs.d/lisp/my/my-hnreader.el b/emacs/.emacs.d/lisp/my/my-hnreader.el index 4176f8b..6106d29 100644 --- a/emacs/.emacs.d/lisp/my/my-hnreader.el +++ b/emacs/.emacs.d/lisp/my/my-hnreader.el @@ -3,8 +3,6 @@ ;; Copyright (C) 2023 Free Software Foundation. ;; Author: Yuchen Pei -;; Thanh Vuong -;; Maintainer: Yuchen Pei ;; Package-Requires: ((emacs "28.2")) ;; This file is part of dotfiles. diff --git a/emacs/.emacs.d/lisp/my/my-org.el b/emacs/.emacs.d/lisp/my/my-org.el index 4c69484..4b8ad44 100644 --- a/emacs/.emacs.d/lisp/my/my-org.el +++ b/emacs/.emacs.d/lisp/my/my-org.el @@ -95,8 +95,23 @@ With a prefix, insert inactive dates. (save-restriction (org-narrow-to-subtree) (goto-char (point-min)) - (when (re-search-forward "^\\s-*:PROPERTIES:" nil t) - (org-hide-drawer-toggle))))) + (while (re-search-forward "^\\ *:[A-Z]+:\\ *$" nil t) + (org-hide-drawer-toggle) + (re-search-forward "^\\ *:END:\\ *$" nil t))))) + +(defun my-org-beginning-of-line-or-indent () + "Move to org beginning of line, or indentation" + (interactive) + (if (bolp) + (back-to-indentation) + (org-beginning-of-line))) + +(defun my-org-kill-line (&optional arg) + "Call `my-kill-forward' or `org-kill-line' with a prefix arg." + (interactive "P") + (if arg + (org-kill-line) + (my-kill-forward))) (defun my-org-open-default-notes-file () (interactive) diff --git a/emacs/.emacs.d/lisp/my/my-package.el b/emacs/.emacs.d/lisp/my/my-package.el index 1f35a5e..da4ff6f 100644 --- a/emacs/.emacs.d/lisp/my/my-package.el +++ b/emacs/.emacs.d/lisp/my/my-package.el @@ -3,8 +3,6 @@ ;; Copyright (C) 2023 Free Software Foundation. ;; Author: Yuchen Pei -;; Protesilaos Stavrou -;; Maintainer: Yuchen Pei ;; Package-Requires: ((emacs "28.2")) ;; This file is part of dotfiles. @@ -259,5 +257,10 @@ same name, cancel that one first." (t (append (my-collect-my-setqd-vars (car xs)) (my-collect-my-setqd-vars (cdr xs)))))) +(defsubst my-add-hooks (function hooks) + "Add function to hooks" + (dolist (hook hooks) + (add-hook hook function))) + (provide 'my-package) ;;; my-package.el ends here diff --git a/emacs/.emacs.d/lisp/my/my-prog.el b/emacs/.emacs.d/lisp/my/my-prog.el index 4794ff2..ca54ad9 100644 --- a/emacs/.emacs.d/lisp/my/my-prog.el +++ b/emacs/.emacs.d/lisp/my/my-prog.el @@ -48,12 +48,30 @@ (comint-previous-prompt 1) (recenter 0 t)) -;; FIXME: not working properly -(defun my-restart-shell () +(defun my-comint-restart () (interactive) - (ignore-error (comint-send-eof)) - (shell (current-buffer)) - (message "Shell restarted!")) + (ignore-errors (comint-send-eof)) + (sleep-for .1) + (my-comint-revive)) + +(defvar my-comint-revive-commands + '((shell-mode . my-shell-revive) + (inferior-emacs-lisp-mode . ielm)) + "Alist of commands for each comint derived mode to revive a \"no + process\" buffer ") + +(defun my-shell-revive () + (interactive) + (shell (current-buffer))) + +(defun my-comint-revive () + "Revive a comint process after death" + (interactive) + (if-let ((revive-command (alist-get major-mode + my-comint-revive-commands))) + (funcall revive-command) + (error "I don't know how to restart in %S" major-mode)) + ) (defun my-shell-disable-company-if-remote () (when (and (fboundp 'company-mode) @@ -444,5 +462,16 @@ left and the source buffer on the right. (eval-region (region-beginning) (region-end) t) (eval-defun arg))) +(defun my-insert-current-prefix () + "Insert file basename followed by a dash" + (interactive) + (insert (file-name-base (buffer-file-name)) "-")) + +(defun my-prog-modes-setup () + (setq-local comment-auto-fill-only-comments t) + (auto-fill-mode) + (display-line-numbers-mode) + (setq tab-width 2)) + (provide 'my-prog) ;;; my-prog.el ends here diff --git a/emacs/.emacs.d/lisp/my/my-project.el b/emacs/.emacs.d/lisp/my/my-project.el index 21a05f1..6835487 100644 --- a/emacs/.emacs.d/lisp/my/my-project.el +++ b/emacs/.emacs.d/lisp/my/my-project.el @@ -61,6 +61,51 @@ "Remember all projects under `my-projects-root-dirs'." (pcase-dolist (`(_ . ,dir) my-projects-root-dirs) (project-remember-projects-under dir))) + +;; Override project-remember-projects-under The original function is +;; buggy: it does not look for projects in surdirs unless recursive. +(defun my-project-remember-projects-under (dir &optional recursive) + "Index all projects below a directory DIR. +If RECURSIVE is non-nil, recurse into all subdirectories to find +more projects. After finishing, a message is printed summarizing +the progress. The function returns the number of detected +projects." + (interactive "DDirectory: \nP") + (project--ensure-read-project-list) + (let ((queue (directory-files + dir + t + directory-files-no-dot-files-regexp)) + (count 0) + (known (make-hash-table + :size (* 2 (length project--list)) + :test #'equal ))) + (dolist (project (mapcar #'car project--list)) + (puthash project t known)) + (while queue + (when-let ((subdir (pop queue)) + ((file-directory-p subdir))) + (when-let ((project (project--find-in-directory subdir)) + (project-root (project-root project)) + ((not (gethash project-root known)))) + (project-remember-project project t) + (puthash project-root t known) + (message "Found %s..." project-root) + (setq count (1+ count))) + (when (and recursive (file-directory-p subdir)) + (setq queue + (nconc + (directory-files + subdir t directory-files-no-dot-files-regexp t) + queue))))) + (unless (eq recursive 'in-progress) + (if (zerop count) + (message "No projects were found") + (project--write-project-list) + (message "%d project%s were found" + count (if (= count 1) "" "s")))) + count)) + ;; FIXME: do we really need this or does the project package already ;; do so? (defun my-project-read-project () diff --git a/emacs/.emacs.d/lisp/my/my-system.el b/emacs/.emacs.d/lisp/my/my-system.el new file mode 100644 index 0000000..f22c982 --- /dev/null +++ b/emacs/.emacs.d/lisp/my/my-system.el @@ -0,0 +1,36 @@ +;;; my-system.el -- Extensions to emacs builtins working with the underlying system -*- lexical-binding: t -*- + +;; Copyright (C) 2023 Free Software Foundation. + +;; Author: Yuchen Pei +;; Package-Requires: ((emacs "28.2")) + +;; This file is part of dotted. + +;; dotted is free software: you can redistribute it and/or modify it under +;; the terms of the GNU Affero General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; dotted is distributed in the hope that it will be useful, but WITHOUT +;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +;; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General +;; Public License for more details. + +;; You should have received a copy of the GNU Affero General Public +;; License along with dotted. If not, see . + +;;; Commentary: + +;; Extensions to emacs builtins working with the underlying system. + +;;; Code: + +(defun my-file-handlers-without-tramp () + (seq-filter + (lambda (pair) + (not (string-match-p "^tramp" (symbol-name (cdr pair))))) + file-name-handler-alist)) + +(provide 'my-system) +;;; my-system.el ends here diff --git a/emacs/.emacs.d/lisp/my/my-utils.el b/emacs/.emacs.d/lisp/my/my-utils.el index 7f36fae..fcaba11 100644 --- a/emacs/.emacs.d/lisp/my/my-utils.el +++ b/emacs/.emacs.d/lisp/my/my-utils.el @@ -406,4 +406,9 @@ With optional N, search in the Nth line from point." (looking-at (alist-get type my--line-regexp-alist)))))) +(defun my-quit-emacs (arg) + (interactive "P") + (save-some-buffers t t) + (kill-emacs)) + (provide 'my-utils) diff --git a/misc/.config/zathura/zathurarc b/misc/.config/zathura/zathurarc new file mode 100644 index 0000000..23cfaa7 --- /dev/null +++ b/misc/.config/zathura/zathurarc @@ -0,0 +1,2 @@ +set vertical-center true +set selection-clipboard clipboard \ No newline at end of file -- cgit v1.2.3