emacs/lisp/obsolete.el
2024-05-25 21:05:33 -08:00

291 lines
9.8 KiB
EmacsLisp

;;; obsolete.el --- code I don't use anymore -*- lexical-binding: t; -*-
;; Copyright (C) 2023 mir
;; Author: mir <mir@mirmarq42.xyz>
;; Keywords:local,maint
;; This program 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 program 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 <https://www.gnu.org/licenses/>.
;;; Commentary:
;; All the code here is taken from my other files. This is never meant to be
;; loaded.
;;; Code:
(error "Please don't load `obsolete.el', it's obsolete.")
;; Emacs App Framework. Definitely pretty broken but it worked once
(unless (eq system-type 'windows-nt)
(use-package eaf
:git (:host github :repo "emacs-eaf/emacs-application-framework"
:files ("*.el" "*.py" "core" "app" "*.json")
:pre-build (("python" "install-eaf.py"
"--install" "pdf-viewer" "browser"
"--ignore-sys-deps")))
:commands (eaf-open-browser eaf-open-url-at-point)
:config (add-to-list 'load-path (expand-file-name "app/" eaf-source-dir))
(if (and (string= (getenv "XDG_CURRENT_DESKTOP") "Hyprland")
(featurep 'hypop))
(defun eaf--get-frame-coordinate ()
"We need fetch Emacs coordinate to adjust coordinate of EAF if it running on system not support cross-process reparent technology.
Such as, wayland native, macOS etc.
This is redefined for use with `hypop' library because multiple Emacs frames may be open."
(cond ((string-equal (getenv "XDG_CURRENT_DESKTOP") "sway")
(eaf--split-number (shell-command-to-string (concat eaf-build-dir "swaymsg-treefetch/swaymsg-rectfetcher.sh emacs"))))
((string-equal (getenv "XDG_CURRENT_DESKTOP") "Hyprland")
(let ((clients (json-parse-string (shell-command-to-string "hyprctl -j clients")))
(coordinate))
(dotimes (i (length clients))
(when (and (equal (gethash "pid" (aref clients i)) (emacs-pid))
(not (string= (gethash "title" (aref clients i)) hypop--frame-name)))
(setq coordinate (gethash "at" (aref clients i)))))
(list (aref coordinate 0) (aref coordinate 1))))
((eaf-emacs-running-in-wayland-native)
(require 'dbus)
(let* ((coordinate (eaf--split-number
(dbus-call-method :session "org.gnome.Shell" "/org/eaf/wayland" "org.eaf.wayland" "get_emacs_window_coordinate" :timeout 1000)
","))
;; HiDPI need except by `frame-scale-factor'.
(frame-x (truncate (/ (car coordinate) (frame-scale-factor))))
(frame-y (truncate (/ (cadr coordinate) (frame-scale-factor)))))
(list frame-x frame-y)))
(t (list 0 0)))))
(use-package eaf-browser
:git nil
:after eaf
:custom
(eaf-browser-continue-where-left-off t)
(eaf-browser-enable-adblocker t))))
;;; clojure - probably okay just not using it
;; Java never looked so useful...
(use-package clojure-mode
:mode "\\.cljs\\'")
(use-package inf-clojure
:after clojure-mode)
;; or an okay language
(use-package cider
:after clojure-mode)
;; transient posframes cant get it working, broken
(use-package transient-posframe
;; :after magit
:if (display-graphic-p)
:config
(transient-posframe-mode)
;; (add-to-list 'display-buffer-alist
;; '(" *transient*" . transient-posframe--show-buffer))
)
;; elpaca eldoc stuff, probably not good anymore
;; see https://www.reddit.com/r/emacs/comments/1937vaz/emacs_291_on_windows_install_magit_requires_seq/?rdt=48529
;; seq version workaround
(defun +elpaca-unload-seq (e)
(and (featurep 'seq) (unload-feature 'seq t))
(elpaca--continue-build e))
(defun +elpaca-seq-build-steps ()
(append (butlast (if (file-exists-p (expand-file-name "seq" elpaca-builds-directory))
elpaca--pre-built-steps elpaca-build-steps))
(list '+elpaca-unload-seq 'elpaca--activate-package)))
(elpaca seq :build (+elpaca-seq-build-steps))
;; eldoc version workarounds...
(defun global-eldoc-mode (&rest args)
"Placeholder function. Do nothing and return nil."
nil)
(defun +elpaca-unload-eldoc (e)
(and (featurep 'eldoc) (unload-feature 'eldoc t))
(elpaca--continue-build e))
(defun +elpaca-eldoc-build-steps ()
(append (butlast (if (file-exists-p (expand-file-name "eldoc" elpaca-builds-directory))
elpaca--pre-built-steps elpaca-build-steps))
(list '+elpaca-unload-eldoc 'elpaca--activate-package)))
(elpaca eldoc :build (+elpaca-eldoc-build-steps))
;; scribble SVGs in org buffers like it's 2005 (idk I was a baby then)
(use-package edraw
:elpaca (:repo "https://github.com/misohena/el-easydraw")
:after org
:config
(require 'edraw-org)
(edraw-org-setup-default)
;; following function taken from https://github.com/wn/doom.d/blob/46ca46f2ef21e933fb76b1568be1a62b262ed288/config.el#L47
(defun org-mode-open-edraw (&optional filename)
(interactive)
(let ((filename (or filename
(concat "./"
(file-relative-name
(read-file-name (edraw-msg "Write svg file: ")
default-directory)
default-directory)))))
(insert (format "[[edraw:file=%s]]" filename))
(backward-char)
(org-return))))
(use-package yascroll
:diminish
:defer 1
;; :if (not (display-graphic-p))
:custom (yascroll:delay-to-hide nil)
;; :custom-face
;; (yascroll:thumb-fringe
;; ((t (:background "green3"))))
:config
(defun yascroll:make-thumb-overlay-fringe (left-or-right)
"Make thumb overlay on the LEFT-OR-RIGHT fringe."
(let* ((pos (point))
;; If `pos' is at the beginning of line, overlay of the
;; fringe will be on the previous visual line.
(pos (if (= (line-end-position) pos) pos (1+ pos)))
;; below originally said `filled-rectangle' instead of `empty-line'.
;; Changed to fix transparency.
(display-string `(,left-or-right empty-line yascroll:thumb-fringe))
(after-string (propertize "." 'display display-string))
(overlay (make-overlay pos pos)))
(overlay-put overlay 'after-string after-string)
(overlay-put overlay 'fringe-helper t)
(overlay-put overlay 'window (selected-window))
(overlay-put overlay 'priority yascroll:priority)
overlay))
(add-to-list 'yascroll:disabled-modes 'org-mode)
;; (global-yascroll-bar-mode 1)
)
(remove '(?< . ?>) electric-pair-pairs)
(electric-pair-mode -1)
(defvar org-electric-pairs '((?_ . ?_)
(?/ . ?/)
(?* . ?*)
(?+ . ?+)
(?~ . ?~)
(?= . ?=))
"Electric pairs for org-mode.
See https://emacs.stackexchange.com/questions/2538/how-to-define-additional-mode-specific-pairs-for-electric-pair-mode")
(defun org-add-electric-pairs ()
(setq-local electric-pair-pairs (append electric-pair-pairs org-electric-pairs))
(setq-local electric-pair-text-pairs electric-pair-pairs))
(add-hook 'org-mode-hook 'org-add-electric-pairs)
(require 'mir-orgstuff)
(general-define-key
:states '(normal visual insert)
:keymaps 'org-mode-map
"_" 'mir/org-dwim-char
"/" 'mir/org-dwim-char
"*" 'mir/org-dwim-char
"+" 'mir/org-dwim-char
"~" 'mir/org-dwim-char
"=" 'mir/org-dwim-char)
(use-package org-modern-indent
:elpaca (:host github :repo "jdtsmith/org-modern-indent")
:diminish org-indent-mode
:hook (org-mode . org-indent-mode)
:config (add-hook 'org-mode-hook #'org-modern-indent-mode 90))
(use-package org-block-capf
:elpaca (org-block-capf
:host github
:repo "xenodium/org-block-capf")
:after org
:init (add-hook 'org-mode-hook
#'org-block-capf-add-to-completion-at-point-functions))
(use-package org-pretty-table
:elpaca (org-pretty-table
:host github
:repo "Fuco1/org-pretty-table")
:diminish
:hook (org-mode . org-pretty-table-mode))
;; Tree-sitter (disabled because broken?)
(use-package treesit-auto
:elpaca (treesit-auto
:host github
:repo "renzmann/treesit-auto")
:custom (treesit-auto-install 'prompt)
;; :init (add-to-list 'treesit-auto-fallback-alist '(bash-ts-mode . sh-mode))
)
;; see https://www.reddit.com/r/emacs/comments/xyo2fo/orgmode_vterm_tmux/
(use-package ob-tmux
:after (org dash)
:config
(setq org-src-lang-modes (-replace
'("tmux" . sh)
'("tmux" . powershell)
org-src-lang-modes))
:custom
(org-babel-default-header-args:tmux
'((:results . "display")
(:session . "default")
(:socket . nil)))
(org-babel-tmux-session-prefix "ob-")
(org-babel-tmux-terminal "/home/mir/.local/bin/emacs-term-shim.sh")
(org-babel-tmux-terminal-opts))
(use-package org-modern
:after org
:custom
(org-modern-tag nil)
(org-modern-todo nil)
(org-modern-block-name nil)
(org-modern-table nil)
(org-modern-hide-stars nil)
(org-modern-star nil)
;; (org-modern-block-fringe 16)
:hook (org-mode . org-modern-mode)
:config
)
;; svg-tags; disabled because reasons
(use-package svg-tag-mode
:elpaca (svg-tag-mode
:host github
:repo "rougier/svg-tag-mode")
;; :after org-modern
:hook (org-modern-mode . svg-tag-mode)
:custom (svg-tag-tags
`((,(rx blank (group (= 4 upper)) blank) .
((lambda (tag)
(svg-tag-make tag
:inverse t
:face (intern
(format "org-%s" (downcase tag)))))))
(,(rx (group "#+" (or "begin" "end") "_src")) .
((lambda (tag)
(let* ((begend (string-trim tag "#\\+" "_src"))
(upcased (upcase begend)))
(svg-tag-make upcased
:face 'org-block-begin-line)))))))
)
;; disabled because error and useless
(use-package aggressive-indent
:after paredit
:commands aggressive-indent-mode
:hook (emacs-lisp-mode . aggresssive-indent-mode))
(provide 'obsolete)
;;; obsolete.el ends here