From 3bd2337c74233b4789ba0b8199e0a82d5f899a25 Mon Sep 17 00:00:00 2001 From: Yann Herklotz Date: Tue, 31 Jan 2023 21:40:44 +0000 Subject: Add unfill-paragraph, darkroom and whitespace cleanup --- init.el | 103 ++++++++++++++++++++++++++++++++++++++++++------ ymh-emacs/ymh-common.el | 10 +++++ 2 files changed, 100 insertions(+), 13 deletions(-) diff --git a/init.el b/init.el index 29cbc68..c3b6fc3 100644 --- a/init.el +++ b/init.el @@ -27,6 +27,8 @@ (global-set-key (kbd "C-c l") #'org-store-link) (global-set-key (kbd "C-c c") #'org-capture) +(define-key global-map (kbd "M-Q") #'ymh/unfill-paragraph) + (define-prefix-command 'ymh-map) (global-set-key (kbd "C-c y") 'ymh-map) (define-key ymh-map (kbd "o") #'ymh/reset-coq-windows) @@ -36,6 +38,11 @@ (define-key ymh-map (kbd "C-n") #'org-next-link) (defvar ymh/org-base-dir "~/Dropbox/org" +(defvar ymh/keyboard :white-split + "Define which keyboard is being used. + +Should be one of `:white-split', `:modified' or `:default'") + "Contains the base directory for Org files.") (defvar ymh/bib-base-dir "~/Dropbox/bibliography" "Contains the base directory for the bibliography related files.") @@ -141,8 +148,6 @@ (setq auth-sources '("~/.authinfo" "~/.authinfo.gpg" "~/.netrc")) (setq wdired-allow-to-change-permissions t) - - (add-hook 'text-mode-hook #'visual-line-mode) :config (unless ymh/macos-p (menu-bar-mode -1)) @@ -150,6 +155,11 @@ (scroll-bar-mode -1) (column-number-mode 1) + (global-display-fill-column-indicator-mode) + + (add-hook 'text-mode-hook #'visual-line-mode) + (add-hook 'text-mode-hook #'auto-fill-mode) + ;; Enable those (dolist (c '(overwrite-mode narrow-to-region narrow-to-page upcase-region downcase-region)) (put c 'disabled nil)) @@ -167,16 +177,51 @@ ;; Mac configuration (when ymh/macos-p - (setq mac-right-option-modifier 'hyper) - (setq mac-command-modifier 'meta) - (setq mac-option-modifier 'super) - (add-hook 'ns-system-appearance-change-functions #'ymh/apply-theme)) - - (global-display-fill-column-indicator-mode)) + (cl-case ymh/keyboard + (:white-split (setq mac-right-option-modifier 'hyper + mac-command-modifier 'super + mac-option-modifier 'meta)) + (:modified (setq mac-right-option-modifier 'meta + mac-command-modifier 'super + mac-option-modifier 'hyper)) + (:default (setq mac-right-option-modifier 'hyper + mac-command-modifier 'meta + mac-option-modifier 'super))) + (add-hook 'ns-system-appearance-change-functions #'ymh/apply-theme))) + +(use-package time + :init + (setq display-time-24hr-format t) + (setq display-time-default-load-average nil) + (setq display-time-day-and-date t) + :config + (display-time-mode 1)) (use-package ymh-diary :load-path "ymh-emacs") +(use-package whitespace + :config + (defun ymh/add-hook-before-save-hook () + "Add a before-save hook for whitespace cleanup." + (add-hook 'before-save-hook #'whitespace-cleanup 0 :local)) + (add-hook 'text-mode-hook #'ymh/add-hook-before-save-hook) + (add-hook 'dafny-mode-hook #'ymh/add-hook-before-save-hook)) + +(use-package company + :ensure t + :bind (:map company-mode-map + ("M-n" . company-complete-common-or-cycle)) + :hook scala-mode + :init + (setq company-idle-delay nil)) + +(use-package exec-path-from-shell + :ensure t + :config + (when (memq window-system '(mac ns x)) + (exec-path-from-shell-initialize))) + (use-package shr :init (setq shr-use-fonts nil) @@ -329,6 +374,7 @@ https://yannherklotz.com")) (use-package modus-themes :ensure t + :bind (("" . modus-themes-toggle)) :init (setq modus-themes-common-palette-overrides '((bg-mode-line-active bg-cyan-subtle) @@ -571,9 +617,13 @@ https://yannherklotz.com")) (use-package boogie-friends :ensure t + :init + (setq flycheck-inferior-dafny-executable "/Users/ymh/.vscode/extensions/dafny-lang.ide-vscode-3.0.4/out/resources/3.11.0/github/dafny/DafnyServer") + (setq dafny-verification-backend 'server) + (setq boogie-friends-symbols-alist nil) :config - (setq flycheck-dafny-executable (executable-find "dafny")) - (setq dafny-verification-backend 'cli)) + (add-hook 'dafny-mode-hook + (lambda () (prettify-symbols-mode -1)))) (use-package direnv :ensure t @@ -787,7 +837,7 @@ https://yannherklotz.com")) (use-package alectryon :ensure t - :hook (coq-mode . alectryon-mode) + :hook coq-mode :delight alectryon-mode :config (when ymh/macos-p @@ -848,11 +898,36 @@ https://yannherklotz.com")) :config (global-hungry-delete-mode)) +(use-package scala-mode + :ensure t + :defer t + :interpreter ("scala" . scala-mode) + :config + (add-hook 'scala-mode-hook + (lambda () + (add-hook 'before-save-hook #'eglot-format 0 :local) + (setq fill-column 120)))) + +(use-package sbt-mode + :ensure t + :defer t + :commands sbt-start sbt-command + :config + ;; WORKAROUND: https://github.com/ensime/emacs-sbt-mode/issues/31 + ;; allows using SPACE when in the minibuffer + (substitute-key-definition + 'minibuffer-complete-word + 'self-insert-command + minibuffer-local-completion-map) + ;; sbt-supershell kills sbt-mode: https://github.com/hvesalai/emacs-sbt-mode/issues/152 + (setq sbt:program-options '("-Dsbt.supershell=false"))) + (use-package eglot :if (not ymh/emacs-29-p) :ensure t) (use-package eglot + :hook (scala-mode . eglot-ensure) :config (add-to-list 'eglot-server-programs '(prolog-mode @@ -915,10 +990,12 @@ https://yannherklotz.com")) (use-package darkroom :ensure t + :hook (text-mode . darkroom-tentative-mode) :init (setq darkroom-text-scale-increase 1) - :config - (add-hook 'text-mode-hook #'darkroom-tentative-mode)) + +(use-package org-ql + :ensure t) (use-package agda2-mode :if (executable-find "agda-mode") diff --git a/ymh-emacs/ymh-common.el b/ymh-emacs/ymh-common.el index 660a4a4..3786016 100644 --- a/ymh-emacs/ymh-common.el +++ b/ymh-emacs/ymh-common.el @@ -49,6 +49,16 @@ (insert "%\n") (self-insert-command 1))) + +;;; Stefan Monnier: It is the opposite of fill-paragraph. +(defun ymh/unfill-paragraph (&optional region) + "Takes a multi-line paragraph and makes it into a single line of text." + (interactive (progn (barf-if-buffer-read-only) '(t))) + (let ((fill-column (point-max)) + ;; This would override `fill-column' if it's an integer. + (emacs-lisp-docstring-fill-column t)) + (fill-paragraph nil region))) + (provide 'ymh-common) ;;; ymh-common.el ends here -- cgit