diff options
author | Marc Coquand <marc@mccd.space> | 2024-10-07 17:58:47 +0300 |
---|---|---|
committer | Marc Coquand <marc@mccd.space> | 2024-10-07 17:58:47 +0300 |
commit | ea8e480979f45624dc94d4695275e70518cce877 (patch) | |
tree | 3b79201fc43a75ad01e6228a6da0b661d071e3c9 | |
parent | 03c6ace4604899de7c7b3a8d4b80e2698e07fa15 (diff) | |
download | bsd-ea8e480979f45624dc94d4695275e70518cce877.tar.gz bsd-ea8e480979f45624dc94d4695275e70518cce877.tar.bz2 bsd-ea8e480979f45624dc94d4695275e70518cce877.zip |
.
-rw-r--r-- | emacs | 19 | ||||
-rw-r--r-- | emacs.d/elisp/almost-mono-themes.el | 205 | ||||
-rw-r--r-- | emacs.d/elisp/org-link-minor-mode.el | 137 |
3 files changed, 354 insertions, 7 deletions
@@ -1,12 +1,12 @@ (fset 'yes-or-no-p 'y-or-n-p) -(set-face-attribute 'default nil :height 150) + ;; Put Emacs auto-save and backup files to /tmp (defconst emacs-tmp-dir (expand-file-name (format "emacs%d" (user-uid)) temporary-file-directory)) (add-to-list 'load-path "~/.emacs.d/elisp") -(setq +(setq ;; Visual inhibit-startup-screen t line-spacing 0.2 @@ -57,9 +57,11 @@ mastodon lem expand-region) + package-archives '(("elpa" . "https://elpa.gnu.org") ("gnu" . "http://elpa.gnu.org/packages/") ("melpa" . "https://melpa.org/packages/") + ("non-gnu" . "https://elpa.nongnu.org/nongnu") ("melpa-stable" . "https://stable.melpa.org/packages/"))) (setq-default fill-column 80 @@ -86,6 +88,7 @@ (column-number-mode) (line-number-mode) (display-time-mode) +(set-face-attribute 'default nil :height 150) ;; activate all thpe packages (in particular autoloads) @@ -234,10 +237,14 @@ :init (ido-mode t)) +(use-package org-link-minor-mode + :ensure nil) (defvar marcc/timestamp-format "%H:%M " "Format for H:M timestamp") + + (defun marcc/timestamp-hour () "Insert a timestamp at the current point. Uses `marcc/timestamp-format' for formatting the date/time." @@ -252,11 +259,11 @@ Uses `marcc/timestamp-format' for formatting the date/time." :hook ((diary-mode . variable-pitch-mode) (diary-fancy-display-mode . variable-pitch-mode) + (diary-mode . org-link-minor-mode) (diary-mode . flyspell-mode)) :config (global-set-key (kbd "C-c d") 'calendar) (calendar-set-date-style 'european) - (define-key diary-mode-map (kbd "C-=") 'marcc/timestamp-hour) (set-face-attribute 'diary nil :inherit 'fixed-pitch) (setq diary-file "~/personal-db/log" calendar-mark-diary-entries-flag t @@ -293,8 +300,6 @@ Uses `marcc/timestamp-format' for formatting the date/time." (use-package erc :ensure t - :hook - ((erc-mode . flyspell-mode)) :config (setq erc-autojoin-channels-alist '(("Libera.Chat" @@ -496,7 +501,7 @@ Uses `marcc/timestamp-format' for formatting the date/time." (global-set-key (kbd "C-x w") 'elfeed)) (use-package mastodon - :ensure t + :defer t :config (setq mastodon-active-user "marcc" @@ -575,7 +580,7 @@ Uses `marcc/timestamp-format' for formatting the date/time." '("/home/mccd/personal-db/notes/carving-my-own-road.org" "/home/mccd/personal-db/notes/emacs-teaches.org" "/home/mccd/personal-db/notes/agency-and-tech.org" "/home/mccd/builds/sustainably/piva.org" "/home/mccd/builds/comma.directory/comma.org" "/home/mccd/personal-db/notes/frugal.org" "/home/mccd/personal-db/notes/inbox.org" "/home/mccd/personal-db/notes/emacs.org" "/home/mccd/personal-db/todo.org")) '(org-fold-core-style 'overlays) '(package-selected-packages - '(web-mode flycheck nix-mode nix-ts-mode avy pdf-tools elfeed-protocol lem yasnippet-snippets elfeed yasnippet smartparens markdown-mode mastodon tldr almost-mono-themes rec-mode magit go-mode expand-region devdocs)) + '(orglink web-mode flycheck nix-mode nix-ts-mode avy pdf-tools elfeed-protocol lem yasnippet-snippets elfeed yasnippet smartparens markdown-mode mastodon tldr almost-mono-themes rec-mode magit go-mode expand-region devdocs)) '(tab-bar-format '(tab-bar-separator tab-bar-format-align-right tab-bar-format-global)) '(yank-from-kill-ring-rotate t)) diff --git a/emacs.d/elisp/almost-mono-themes.el b/emacs.d/elisp/almost-mono-themes.el new file mode 100644 index 0000000..4b7769e --- /dev/null +++ b/emacs.d/elisp/almost-mono-themes.el @@ -0,0 +1,205 @@ +;;; almost-mono-themes.el --- Almost monochromatic color themes -*- lexical-binding: t; -*- + +;; Copyright (C) 2019 - 2022 John Olsson + +;; Author: John Olsson <john@cryon.se> +;; Maintainer: John Olsson <john@cryon.se> +;; URL: https://github.com/cryon/almost-mono-themes +;; Created: 9th May 2019 +;; Version: 1.0.0 +;; Keywords: faces +;; Package-Requires: ((emacs "24")) + +;; This file is free software: you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published +;; by the Free Software Foundation, either version 3 of the License, +;; or (at your option) any later version. + +;; This file 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 +;; General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this file. If not, see <http://www.gnu.org/licenses/>. + +;;; Commentary: + +;; A suite of almost monochrome Emacs themes + +;;; Code: + +(defconst almost-mono-themes-colors + '((white . ((background . "#ffffff") + (foreground . "#000000") + (weak . "#888888") + (weaker . "#dddddd") + (weakest . "#efefef") + (highlight . "#fda50f") + (warning . "#ff0000") + (success . "#00ff00") + (string . "#3c5e2b"))) + + (black . ((background . "#000000") + (foreground . "#ffffff") + (weak . "#aaaaaa") + (weaker . "#666666") + (weakest . "#222222") + (highlight . "#fda50f") + (warning . "#ff0000") + (success . "#00ff00") + (string . "#a7bca4"))) + + (gray . ((background . "#2b2b2b") + (foreground . "#ffffff") + (weak . "#aaaaaa") + (weaker . "#666666") + (weakest . "#222222") + (highlight . "#fda50f") + (warning . "#ff0000") + (success . "#00ff00") + (string . "#a7bca4"))) + + (cream . ((background . "#f0e5da") + (foreground . "#000000") + (weak . "#7d7165") + (weaker . "#c4baaf") + (weakest . "#dbd0c5") + (highlight . "#fda50f") + (warning . "#ff0000") + (success . "#00ff00") + (string . "#3c5e2b"))))) + +(defmacro almost-mono-themes--variant-with-colors (variant &rest body) + "Execute BODY in a scope where the different colors for given VARIANT is bound." + `(let* ((colors (or (cdr (assoc ,variant almost-mono-themes-colors)) + (error "No such theme variant"))) + (background (cdr (assoc 'background colors))) + (foreground (cdr (assoc 'foreground colors))) + (weak (cdr (assoc 'weak colors))) + (weaker (cdr (assoc 'weaker colors))) + (weakest (cdr (assoc 'weakest colors))) + (highlight (cdr (assoc 'highlight colors))) + (warning (cdr (assoc 'warning colors))) + (success (cdr (assoc 'success colors))) + (string (cdr (assoc 'string colors)))) + ,@body)) + +(defmacro almost-mono-themes--faces-spec () + "Provide the faces specification." + (quote + (mapcar + (lambda (entry) (list (car entry) `((t ,@(cdr entry))))) + `( + + ;; default + (default (:background ,background :foreground ,foreground)) + (fringe (:background ,background)) + (region (:background ,highlight :foreground ,foreground)) + (show-paren-match (:background ,background :foreground ,success :bold t)) + (show-paren-mismatch (:background ,background :foreground ,warning :bold t)) + (minibuffer-prompt (:weight bold :foreground ,foreground)) + (isearch (:background ,weak :foreground ,foreground :bold t)) + (lazy-highlight (:background ,weaker :foreground ,foreground)) + (link (:underline t)) + + ;; mode line + (mode-line (:box (:line-width -1 :color ,weaker) + :background ,weakest :foreground ,foreground)) + + (mode-line-inactive (:box (:line-width -1 :color ,weaker) + :background ,background :foreground ,weaker)) + + ;; font lock + (font-lock-keyword-face (:bold t)) + (font-lock-function-name-face (:bold t)) + (font-lock-variable-name-face (:foreground ,foreground)) + (font-lock-warning-face (:foreground ,foreground :underline (:color ,warning :style wave))) + (font-lock-builtin-face (:bold t)) + (font-lock-variable-name-face (:foreground ,foreground :italic t)) + (font-lock-constant-face (:bold t :italic t)) + (font-lock-type-face (:italic t)) + (font-lock-preprocessor-face (:italic t)) + (font-lock-comment-face (:foreground ,weak :italic t)) + (font-lock-string-face (:foreground ,string)) + (font-lock-doc-face (:inherit font-lock-comment-face)) + (line-number (:foreground ,weaker)) + (linum (:inherit line-number)) + (vertical-border (:foreground ,weaker)) + + ;; eshell + (eshell-prompt (:foreground ,foreground :bold t)) + (eshell-ls-directory (:foreground ,foreground :bold t)) + (eshell-ls-archive (:inherit eshell-ls-unreadable)) + (eshell-ls-backup (:inherit eshell-ls-unreadable)) + (eshell-ls-clutter (:inherit eshell-ls-unreadable)) + (eshell-ls-executable (:inherit eshell-ls-unreadable)) + (eshell-ls-missing (:inherit eshell-ls-unreadable)) + (eshell-ls-product (:inherit eshell-ls-unreadable)) + (eshell-ls-readonly (:inherit eshell-ls-unreadable)) + (eshell-ls-special (:inherit eshell-ls-unreadable)) + (eshell-ls-symlink (:inherit eshell-ls-unreadable)) + + ;; company mode + (company-tooltip (:background ,weakest :foreground ,foreground)) + (company-tooltip-selection (:background ,weaker :foreground ,foreground)) + ;;(company-tooltip-search (:background "#ff0000" :foreground "#00ff00")) + (company-tooltip-common (:bold t)) + (company-tooltip-common-selection (:bold t)) + (company-scrollbar-bg (:background ,weaker)) + (company-scrollbar-fg (:background ,weak)) + (company-tooltip-annotation-selection (:background ,weaker :foreground ,foreground :italic t)) + (company-tooltip-annotation (:background ,weakest :foreground ,weak :italic t)) + + ;; git gutter + (git-gutter:modified (:background ,highlight :foreground ,highlight)) + (git-gutter:added (:background ,success :foreground ,success)) + (git-gutter:deleted (:background ,warning :foreground ,warning)) + + ;; diff hl + (diff-hl-change (:background ,highlight :foreground ,highlight)) + (diff-hl-insert (:background ,success :foreground ,success)) + (diff-hl-delete (:background ,warning :foreground ,warning)) + + ;; hl line + (hl-line (:background ,weakest)) + (highlight-current-line-face (:inherit hl-line)) + + ;; ido + (ido-first-match (:bold t)) + (ido-only-match (:bold t)) + (ido-subdir (:italic t)) + (ido-virtual (:foreground ,weak)) + (ido-vertical-match-face (:bold t :italic nil)) + + ;; org mode + (org-table (:foreground ,weak)) + + )))) + + +(defun almost-mono-themes--variant-name (variant) + "Create symbol for color theme variant VARIANT." + (intern (format "almost-mono-%s" (symbol-name variant)))) + +(defmacro almost-mono-themes--define-theme (variant) + "Define a theme for the almost-mono variant VARIANT." + (let ((name (almost-mono-themes--variant-name variant)) + (doc (format "almost mono theme (%s version)" variant))) + `(progn + (deftheme ,name ,doc) + (put ',name 'theme-immediate t) + (almost-mono-themes--variant-with-colors + ',variant + (apply 'custom-theme-set-faces ',name + (almost-mono-themes--faces-spec))) + (provide-theme ',name)))) + +;;;###autoload +(when (and (boundp 'custom-theme-load-path) load-file-name) + (add-to-list 'custom-theme-load-path + (file-name-as-directory (file-name-directory load-file-name)))) + +(provide 'almost-mono-themes) + +;;; almost-mono-themes.el ends here diff --git a/emacs.d/elisp/org-link-minor-mode.el b/emacs.d/elisp/org-link-minor-mode.el new file mode 100644 index 0000000..7f1faaa --- /dev/null +++ b/emacs.d/elisp/org-link-minor-mode.el @@ -0,0 +1,137 @@ +;;; org-link-minor-mode.el --- Enable org-mode links in non-org modes -*- lexical-binding: t; -*- +;; +;; Copyright (C) 2012-2020 +;; +;; Author: Sean O'Halpin <sean.ohalpin@gmail.com> +;; Maintainer: Sean O'Halpin <sean.ohalpin@gmail.com> +;; Created: 20120825 +;; Modified: 20200129 +;; Version: 0.0.3 +;; Package-Requires: ((emacs "24.3")) +;; Package-Version: 20200129.0141 +;; Keywords: hypermedia +;; Url: https://github.com/seanohalpin/org-link-minor-mode +;; +;; Changes for org v9: Stefan-W. Hahn <stefan dot hahn at s-hahn dot de> +;; +;; This file is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation; either version 3, or (at your option) +;; any later version. +;; +;; This file 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 General Public License for more details. +;; +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see <http://www.gnu.org/licenses/>. +;; +;;; Commentary: +;; +;; Enables org-mode links of the form: +;; +;; http://www.bbc.co.uk +;; man:emacs +;; info:emacs +;; <http://www.bbc.co.uk> +;; [[http://www.bbc.co.uk][BBC]] +;; [[org-link-minor-mode]] +;; [2012-08-18] +;; <2012-08-18> +;; +;; Note that `org-toggle-link-display' will also work when this mode +;; is enabled. +;; +;;; Code: + +(require 'org-element) + +;; Following declarations are necessary to make the byte compiler happy. + +;; For org v8 compatibility (if used with org v9) +(declare-function org-activate-plain-links "org" (limit)) +(declare-function org-activate-angle-links "org" (limit)) +(declare-function org-activate-bracket-links "org" (limit)) +(declare-function org-decompose-region "org-compat" (beg end)) + +;; For org v9 compatibility (if used with org v8) +(declare-function org-activate-links "org" (limit)) +(declare-function org-activate-dates "org" (limit)) + +(defun org-link-minor-mode--unfontify-region (beg end) + "Remove org-link fontification between BEG and END." + (font-lock-default-unfontify-region beg end) + (let* ((buffer-undo-list t) + (inhibit-read-only t) (inhibit-point-motion-hooks t) + (inhibit-modification-hooks t) + deactivate-mark buffer-file-name buffer-file-truename) + (if (fboundp 'org-decompose-region) + (org-decompose-region beg end) + (decompose-region beg end)) + (remove-text-properties beg end + '(mouse-face t keymap t org-linked-text t + invisible t intangible t + help-echo t rear-nonsticky t + htmlize-link t + org-no-flyspell t org-emphasis t)) + (org-remove-font-lock-display-properties beg end))) + +(defvar org-link-minor-mode-map (make-sparse-keymap) + "Local keymap.") +(make-variable-buffer-local 'org-link-minor-mode-map) + +;;;###autoload +(define-minor-mode org-link-minor-mode + "Toggle display of org-mode style links in non-org-mode buffers." + :lighter " org-link" + :keymap org-link-minor-mode-map + (let ((lk org-highlight-links) + org-link-minor-mode-keywords) + (if (fboundp 'org-activate-links) + ;; from Org v9.2 + (setq org-link-minor-mode-keywords + (list + '(org-activate-links) + (when (memq 'tag lk) '(org-activate-tags (1 'org-tag prepend))) + (when (memq 'radio lk) '(org-activate-target-links (1 'org-link t))) + (when (memq 'date lk) '(org-activate-dates (0 'org-date t))) + (when (memq 'footnote lk) '(org-activate-footnote-links)))) + (setq org-link-minor-mode-keywords + (list + (when (memq 'tag lk) '(org-activate-tags (1 'org-tag prepend))) + (when (memq 'angle lk) '(org-activate-angle-links (0 'org-link t))) + (when (memq 'plain lk) '(org-activate-plain-links (0 'org-link t))) + (when (memq 'bracket lk) '(org-activate-bracket-links (0 'org-link t))) + (when (memq 'radio lk) '(org-activate-target-links (0 'org-link t))) + (when (memq 'date lk) '(org-activate-dates (0 'org-date t))) + (when (memq 'footnote lk) '(org-activate-footnote-links))))) + (if org-link-minor-mode + (if (derived-mode-p 'org-mode) + (progn + (message "org-mode doesn't need org-link-minor-mode") + (org-link-minor-mode -1)) + (font-lock-add-keywords nil org-link-minor-mode-keywords t) + (kill-local-variable 'org-mouse-map) + (setq-local org-mouse-map + (let ((map (make-sparse-keymap))) + (define-key map [return] 'org-open-at-point) + (define-key map [tab] 'org-next-link) + (define-key map [backtab] 'org-previous-link) + (define-key map [mouse-2] 'org-open-at-point) + (define-key map [follow-link] 'mouse-face) + map)) + (setq-local font-lock-unfontify-region-function + 'org-link-minor-mode--unfontify-region) + (setq-local org-descriptive-links nil) + (org-toggle-link-display)) + (unless (derived-mode-p 'org-mode) + (font-lock-remove-keywords nil org-link-minor-mode-keywords) + (setq org-descriptive-links t) + (org-toggle-link-display) + (kill-local-variable 'org-descriptive-links) + (kill-local-variable 'org-mouse-map) + (kill-local-variable 'font-lock-unfontify-region-function))))) + +(provide 'org-link-minor-mode) +;;; org-link-minor-mode.el ends here |