From 685743ec8339a1cdb1f9517f0fa64cb2fce63cd7 Mon Sep 17 00:00:00 2001 From: Vladislav Slobodenyuk Date: Fri, 20 Mar 2026 11:18:00 +0900 Subject: [PATCH] Start of myfeed, minor package changes --- .config.d/05-basic.el | 5 ++ .config.d/10-completion.el | 4 +- load/myfeed.el | 93 ++++++++++++++++++++++++++++++++++++++ post-init.el | 44 ++++++++++-------- 4 files changed, 127 insertions(+), 19 deletions(-) create mode 100644 load/myfeed.el diff --git a/.config.d/05-basic.el b/.config.d/05-basic.el index 3ffdfdf..7b0b931 100644 --- a/.config.d/05-basic.el +++ b/.config.d/05-basic.el @@ -12,6 +12,11 @@ :defer nil :config (direnv-mode)) +;; Sometimes, one must use multiple terminals. +(use-package multi-vterm + :ensure t + :defer t) + ;; Setting this to true makes it so that Emacs saves existing clipboard text ;; into kill ring before replacing it. (setq save-interprogram-paste-before-kill t) diff --git a/.config.d/10-completion.el b/.config.d/10-completion.el index e6fbbc2..bbd73d8 100644 --- a/.config.d/10-completion.el +++ b/.config.d/10-completion.el @@ -167,9 +167,11 @@ (setq icomplete-max-delay-chars 0) (setq icomplete-scroll t) +(keymap-set icomplete-minibuffer-map "TAB" 'icomplete-force-complete) (keymap-set icomplete-minibuffer-map "RET" 'icomplete-force-complete-and-exit) +(keymap-set icomplete-minibuffer-map "C-" 'icomplete-fido-exit) -(setq completion-styles '(initials flex basic partial-completion emacs22)) +(setq completion-styles '(basic partial-completion initials flex emacs22)) (setq completion-auto-select t) ;; Show completion on first call (setq completion-auto-help 'visible) ;; Display *Completions* upon first request (setq completions-format 'one-column) ;; Use only one column diff --git a/load/myfeed.el b/load/myfeed.el new file mode 100644 index 0000000..c3ac51b --- /dev/null +++ b/load/myfeed.el @@ -0,0 +1,93 @@ +;;; myfeed.el --- My RSS reader -*- lexical-binding: t; -*- + +;; Author: iamtoaster +;; Version: 0.0.0 +;; Package-Requires: () +;; Homepage: +;; Keywords: rss, url + +;; This file is not part of GNU Emacs + +;; 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 . + +;;; Commentary: + +;; An RSS feed reader inspired by elfeed. Very early WIP. + +;;; Code: + +(defvar myreader-feeds '() + "Alist of the form (NAME . LINK) of RSS feeds.") + +(defvar myreader--feed-buffers '() + "Alist of buffers in which the asynchronously retrieved pages are +written.") + +(defvar myreader--feed-cache '() + "A list of retrieved entries.") + +;; (defun myreader--eww-render-buffer () +;; "Render the current buffer in EWW." +;; (interactive) +;; (let* ((html (buffer-substring-no-properties (point-min) (point-max))) +;; (source (buffer-name)) +;; (buf (generate-new-buffer (concat "RSS: " source)))) +;; (with-current-buffer buf +;; (insert html) +;; (goto-char (point-min)) +;; (eww-display-html 'utf-8 source nil nil buf)) +;; (switch-to-buffer buf))) + +(defun myreader--render-entry () + (with-current-buffer retr-buf + (message "%s" (buffer-substring (point-min) (point-max))))) + +(defun myreader--update-feed (name) + (let ((buf (alist-get name myreader--feed-buffers))) + ;; TODO figure out a good way to put the thing in cache and then use it + (message "Feed %s; Parsed %s" name (libxml-parse-html-region (point))))) + +(setq myreader-feeds '((scour . "https://scour.ing/@DiToast/rss.xml"))) + +(defun myreader-update-feeds (&optional force) + "Goes through all the feeds defined in `myreader-feeds' and updates them +if necessary. If FORCE is non-nil, updates them unconditionally." + (dolist (entry myreader-feeds) + (let ((name (car entry)) + (link (cdr entry))) + (let ((cache-entry (alist-get name myreader--feed-cache))) + ;; TODO check if entry exists in cache -> check if ttl expired + ;; (if (and cache-entry (alist-get )) + ;; TODO if updating async retrieve the LINK through myreader--feed-buffers + (setq myreader--feed-buffers + (cons + (cons + name + (url-retrieve link (lambda (&rest keys) (myreader--update-feed name)))) + myreader--feed-buffers)))))) + +(defun myreader-revert-item-buffer () + "Reverts the buffer containing the list of RSS entry items from +`myreader--feed-cache'." + (interactive) + ;; TODO go through cache -> check ttl -> update feed if necessary + ;; TODO add the items to the tabulated list + ()) + +;; (setq retr-buf (url-retrieve "https://scour.ing/@DiToast/rss.xml" +;; (lambda (&rest keys) (render-buff)))) + +(provide 'myfeed) + +;;; myfeed.el ends here diff --git a/post-init.el b/post-init.el index 31a4c8c..7aeed85 100644 --- a/post-init.el +++ b/post-init.el @@ -28,6 +28,15 @@ (unless (memq 'use-package-autoloads features) (straight-use-package 'use-package)) +;; This should be loaded as early as possible +(use-package compile-angel + :demand t + :custom + (compile-angel-verbose nil) + :config + (compile-angel-on-load-mode) + (add-hook 'emacs-lisp-mode-hook #'compile-angel-on-save-local-mode)) + ;; Minibuffers and stuff (setq enable-recursive-minibuffers t) (which-key-mode t) @@ -40,10 +49,11 @@ :ensure t) ;; Since diminish was loaded after compile-angel, we cannot use the use-package -;; integration to diminish it. So, we do it manually here. +;; integration to diminish it. So, we do it manually here. Also, built-in modes.1 (diminish 'compile-angel-on-save-local-mode) (diminish 'compile-angel-on-load-mode) (diminish 'eldoc-mode) +(diminish 'which-key-mode) ;; Avoid backups or lockfiles to prevent creating world-readable copies of files (setq create-lockfiles nil) @@ -63,24 +73,22 @@ (setq treesit-font-lock-level 4) ;; NixOS Specific -(unless (functionp 'nix--profile-paths) - (message "Not on NixOS. Will try to install packages usually managed by it through use-package.") - - (use-package compile-angel - :demand t - :custom - (compile-angel-verbose nil) - :config - (compile-angel-on-load-mode) - (add-hook 'emacs-lisp-mode-hook #'compile-angel-on-save-local-mode)) - - (use-package vterm - :defer t - :ensure t) +(if (functionp 'nix--profile-paths) + (progn + (unless (memq 'nix-ts-mode features) + (load "nix-ts-mode" t) + (unless (memq 'nix-ts-mode features) + (warn "Failed to load nix-ts-mode. It is probably not installed.")))) + (progn + (message "Not on NixOS. Will try to install packages usually managed by it through use-package.") + + (use-package vterm + :defer t + :ensure t) - (use-package nix-ts-mode - :defer t - :ensure t)) + (use-package nix-ts-mode + :defer t + :ensure t))) ;; LSP and stuff (add-hook 'nix-ts-mode-hook 'eglot-ensure)