diff options
| author | jao <jao@gnu.org> | 2026-09-06 15:36:38 +0100 |
|---|---|---|
| committer | jao <jao@gnu.org> | 2026-09-06 15:36:38 +0100 |
| commit | 0f8eb65fb807a125dd601cd6b3ee746e6c7b6020 (patch) | |
| tree | 1d394cf0023d0d4e9df41a28c1d4376769c91d77 /lib/eos | |
| parent | 21c34f24c110e57a6c90126c87fee9cd71e85817 (diff) | |
| download | elibs-0f8eb65fb807a125dd601cd6b3ee746e6c7b6020.tar.gz elibs-0f8eb65fb807a125dd601cd6b3ee746e6c7b6020.tar.bz2 | |
a slew of little fixes courtesy of the byte compiler
Diffstat (limited to 'lib/eos')
| -rw-r--r-- | lib/eos/jao-afio.el | 5 | ||||
| -rw-r--r-- | lib/eos/jao-buffers.el | 57 | ||||
| -rw-r--r-- | lib/eos/jao-dirmon.el | 8 | ||||
| -rw-r--r-- | lib/eos/jao-eshell-here.el | 7 | ||||
| -rw-r--r-- | lib/eos/jao-multisession.el | 341 | ||||
| -rw-r--r-- | lib/eos/jao-notify.el | 2 | ||||
| -rw-r--r-- | lib/eos/jao-r2e.el | 233 | ||||
| -rw-r--r-- | lib/eos/jao-shell.el | 4 | ||||
| -rw-r--r-- | lib/eos/jao-sleep.el | 4 | ||||
| -rw-r--r-- | lib/eos/jao-tracking.el | 4 | ||||
| -rw-r--r-- | lib/eos/jao-wayland.el | 1 |
11 files changed, 78 insertions, 588 deletions
diff --git a/lib/eos/jao-afio.el b/lib/eos/jao-afio.el index 525cf60..9e402a2 100644 --- a/lib/eos/jao-afio.el +++ b/lib/eos/jao-afio.el @@ -73,7 +73,7 @@ (assoc 'def jao-afio-frame-parameters))))) (modify-frame-parameters nil params))))) -(defun jao-afio--init (&optional f) +(defun jao-afio--init (&optional _f) (interactive) (jao-afio--current-config ?c) (if jao-afio-use-frames @@ -168,7 +168,8 @@ (find-file (expand-file-name "inbox.org" org-directory)) (delete-other-windows) (gnus) - (jao-gnus--set-summary-line)) + ;; (jao-gnus--set-summary-line) + ) (defun jao-afio--mail-sidebar () (other-window 1) diff --git a/lib/eos/jao-buffers.el b/lib/eos/jao-buffers.el new file mode 100644 index 0000000..5a41486 --- /dev/null +++ b/lib/eos/jao-buffers.el @@ -0,0 +1,57 @@ +;;; jao-buffers.el --- utilities to deal with buffers and windows -*- lexical-binding: t; -*- + +;; Copyright (C) 2026 Jose Antonio Ortega Ruiz + +;; Author: Jose Antonio Ortega Ruiz <mail@jao.io> +;; Keywords: files + +;; 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: + +;; + +;;; Code: + +;;;; attached buffers +(defun jao-display-buffer-below-selected (buffer alist) + (delete-other-windows-vertically) + (display-buffer-below-selected buffer alist)) + +(defun jao-display-below-eldoc (buffer alist) + (let ((w (selected-window))) + (pop-to-buffer "*eldoc*" nil t) + (jao-display-buffer-below-selected buffer alist) + (select-window w t))) + +(defun jao-attached-buffer-entry (name-rx height) + `(,name-rx (display-buffer-reuse-window + jao-display-buffer-below-selected) + (window-height . ,(or height 25)))) + +;;;###autoload +(defmacro jao-with-attached-buffer (name-rx height &rest body) + (declare (indent defun)) + `(let ((display-buffer-alist '(,(jao-attached-buffer-entry name-rx height)))) + ,@body)) + +;;;###autoload +(defun jao-define-attached-buffer (name-rx &optional height) + (add-to-list 'display-buffer-alist + (jao-attached-buffer-entry name-rx height))) + + + +(provide 'jao-buffers) +;;; jao-buffers.el ends here diff --git a/lib/eos/jao-dirmon.el b/lib/eos/jao-dirmon.el index 6a897d3..261433d 100644 --- a/lib/eos/jao-dirmon.el +++ b/lib/eos/jao-dirmon.el @@ -1,6 +1,6 @@ ;;; jao-dirmon.el --- little utility to monitor disk usage -*- lexical-binding: t; -*- -;; Copyright (C) 2022, 2024, 2025 jao +;; Copyright (C) 2022, 2024, 2025, 2026 jao ;; Author: jao <mail@jao.io> ;; Keywords: tools @@ -50,7 +50,7 @@ (defun jao-dirmon--show-deltas (old current deltas) (with-current-buffer (get-buffer-create jao-dirmon-buffer) - (view-mode-disable) + (view-mode -1) (delete-region (point-min) (point-max)) (insert "High deltas since " (car old) "\n\n") (dolist (d (seq-sort-by #'cdr #'> deltas)) @@ -60,8 +60,8 @@ (dolist (c (seq-take-while (lambda (x) (> (cdr x) threshold)) (seq-sort-by #'cdr #'> current))) (insert (format "- %s: %s Mb\n" (car c) (cdr c))))) - (beginning-of-buffer) - (view-mode-enable) + (goto-char (point-min)) + (view-mode 1) (pop-to-buffer (current-buffer) nil t) (when (y-or-n-p "Save current state?") (setf (multisession-value jao-dirmon-last) diff --git a/lib/eos/jao-eshell-here.el b/lib/eos/jao-eshell-here.el index 870e639..8733cb9 100644 --- a/lib/eos/jao-eshell-here.el +++ b/lib/eos/jao-eshell-here.el @@ -1,6 +1,6 @@ ;;; jao-eshell-here.el --- Easy opening of eshell buffers -*- lexical-binding: t; -*- -;; Copyright (C) 2021, 2023 jao +;; Copyright (C) 2021, 2023, 2026 jao ;; Author: jao <mail@jao.io> ;; Keywords: eshell @@ -25,6 +25,11 @@ ;;; Code: (require 'eshell) +(require 'esh-mode) +(require 'em-dirs) +(require 'jao-buffers) +(require 'project) + (defvar jao-eshell-here-display-buffer-alist '(("^\\*eshell" diff --git a/lib/eos/jao-multisession.el b/lib/eos/jao-multisession.el deleted file mode 100644 index 5583fb6..0000000 --- a/lib/eos/jao-multisession.el +++ /dev/null @@ -1,341 +0,0 @@ -;;; multisession.el --- Multisession storage for variables -*- lexical-binding: t; -*- - -;; Copyright (C) 2021-2026 Free Software Foundation, Inc. - -;; This file is part of GNU Emacs. - -;; GNU Emacs 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. - -;; GNU Emacs 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 GNU Emacs. If not, see <https://www.gnu.org/licenses/>. - -;;; Commentary: - -;; This library provides multisession variables for Emacs Lisp, to -;; make them persist between sessions. -;; -;; Use `define-multisession-variable' to define a multisession -;; variable, and `multisession-value' to read its value. Use -;; `list-multisession-values' to list multisession variables. -;; -;; Users might want to customize `multisession-storage' and -;; `multisession-directory'. -;; -;; See Info node `(elisp) Multisession Variables' for more -;; information. - -;;; Code: - -(require 'cl-lib) -(require 'eieio) -(require 'tabulated-list) - -(defcustom multisession-storage 'files - "Storage method for multisession variables. -Valid methods are `sqlite' and `files'." - :type '(choice (const :tag "SQLite" sqlite) - (const :tag "Files" files)) - :version "29.1" - :group 'files) - -(defcustom multisession-directory (expand-file-name "multisession/" - user-emacs-directory) - "Directory to store multisession variables." - :type 'file - :version "29.1" - :group 'files) - -;;;###autoload -(defmacro define-multisession-variable (name initial-value &optional doc - &rest args) - "Make NAME into a multisession variable initialized from INITIAL-VALUE. -DOC should be a doc string, and ARGS are keywords as applicable to -`make-multisession'." - (declare (indent defun)) - (unless (plist-get args :package) - (setq args (nconc (list :package - (replace-regexp-in-string "-.*" "" - (symbol-name name))) - args))) - `(defvar ,name - (make-multisession :key ,(symbol-name name) - :initial-value ,initial-value - ,@args) - ,@(list doc))) - -(defconst multisession--unbound (make-symbol "unbound")) - -(cl-defstruct (multisession - (:constructor nil) - (:constructor multisession--create) - (:conc-name multisession--)) - "A persistent variable that will live across Emacs invocations." - key - (initial-value nil) - package - (storage multisession-storage) - (synchronized nil) - (cached-value multisession--unbound) - (cached-sequence 0)) - -(cl-defun make-multisession (&key key initial-value package synchronized - storage) - "Create a multisession object." - (unless package - (error "No package for the multisession object")) - (unless key - (error "No key for the multisession object")) - (unless (stringp package) - (error "The package has to be a string")) - (unless (stringp key) - (error "The key has to be a string")) - (multisession--create - :key key - :synchronized synchronized - :initial-value initial-value - :package package - :storage (or storage multisession-storage))) - -(defun multisession-value (object) - "Return the value of the multisession OBJECT." - (if (null user-init-file) - ;; If we don't have storage, then just return the value from the - ;; object. - (if (eq (multisession--cached-value object) multisession--unbound) - (multisession--initial-value object) - (multisession--cached-value object)) - ;; We have storage, so we update from storage. - (multisession-backend-value (multisession--storage object) object))) - -(defun multisession--set-value (object value) - "Set the stored value of OBJECT to VALUE." - (if (null user-init-file) - ;; We have no backend, so just store the value. - (setf (multisession--cached-value object) value) - ;; We have a backend. - (multisession--backend-set-value (multisession--storage object) - object value))) - -(defun multisession-delete (object) - "Delete OBJECT from the backend storage." - (multisession--backend-delete (multisession--storage object) object)) - -(gv-define-simple-setter multisession-value multisession--set-value) - -;; Files Backend - -(defun multisession--encode-file-name (name) - (url-hexify-string name)) - -(defun multisession--read-file-value (file object) - (catch 'done - (let ((i 0) - last-error) - (while (< i 10) - (condition-case err - (throw 'done - (with-temp-buffer - (let* ((time (file-attribute-modification-time - (file-attributes file))) - (coding-system-for-read 'utf-8-emacs-unix)) - (insert-file-contents file) - (let ((stored (read (current-buffer)))) - (setf (multisession--cached-value object) stored - (multisession--cached-sequence object) time) - stored)))) - ;; Windows uses OS-level file locking that may preclude - ;; reading the file in some circumstances. In addition, - ;; rename-file is not an atomic operation on MS-Windows, - ;; when the target file already exists, so there could be a - ;; small race window when the file to read doesn't yet - ;; exist. So when these problems happen, wait a bit and retry. - ((permission-denied file-missing) - (setq i (1+ i) - last-error err) - (sleep-for (+ 0.1 (/ (float (random 10)) 10)))))) - (signal (car last-error) (cdr last-error))))) - -(defun multisession--object-file-name (object) - (expand-file-name - (concat "files/" - (multisession--encode-file-name (multisession--package object)) - "/" - (multisession--encode-file-name (multisession--key object)) - ".value") - multisession-directory)) - -(cl-defmethod multisession-backend-value ((_type (eql 'files)) object) - (let ((file (multisession--object-file-name object))) - (cond - ;; We have no value yet; see whether it's stored. - ((eq (multisession--cached-value object) multisession--unbound) - (if (file-exists-p file) - (multisession--read-file-value file object) - ;; Nope; return the initial value. - (multisession--initial-value object))) - ;; We have a value, but we want to update in case some other - ;; Emacs instance has updated. - ((multisession--synchronized object) - (if (and (file-exists-p file) - (time-less-p (multisession--cached-sequence object) - (file-attribute-modification-time - (file-attributes file)))) - (multisession--read-file-value file object) - ;; Nothing, return the cached value. - (multisession--cached-value object))) - ;; Just return the cached value. - (t - (multisession--cached-value object))))) - -(cl-defmethod multisession--backend-set-value ((_type (eql 'files)) - object value) - (let ((file (multisession--object-file-name object)) - (time (current-time))) - ;; Ensure that the directory exists. - (let ((dir (file-name-directory file))) - (unless (file-exists-p dir) - (make-directory dir t))) - (with-temp-buffer - (let ((print-length nil) - (print-circle t) - (print-level nil)) - (prin1 value (current-buffer))) - (goto-char (point-min)) - (condition-case nil - (read (current-buffer)) - (error (error "Unable to store unreadable value: %s" (buffer-string)))) - ;; Write to a temp file in the same directory and rename to the - ;; file for somewhat better atomicity. - (let ((coding-system-for-write 'utf-8-emacs-unix) - (create-lockfiles nil) - (temp (make-temp-name file)) - (write-region-inhibit-fsync nil)) - (write-region (point-min) (point-max) temp nil 'silent) - (set-file-times temp time) - (rename-file temp file t))) - (setf (multisession--cached-sequence object) time - (multisession--cached-value object) value))) - -(cl-defmethod multisession--backend-values ((_type (eql 'files))) - (mapcar (lambda (file) - (let ((bits (file-name-split file))) - (list (url-unhex-string (car (last bits 2))) - (url-unhex-string - (file-name-sans-extension (car (last bits)))) - (with-temp-buffer - (let ((coding-system-for-read 'utf-8-emacs-unix)) - (insert-file-contents file) - (read (current-buffer))))))) - (directory-files-recursively - (expand-file-name "files" multisession-directory) - "\\.value\\'"))) - -(cl-defmethod multisession--backend-delete ((_type (eql 'files)) object) - (let ((file (multisession--object-file-name object))) - (when (file-exists-p file) - (delete-file file)))) - -;; Mode for editing. - -(defvar-keymap multisession-edit-mode-map - :parent tabulated-list-mode-map - "d" #'multisession-delete-value - "e" #'multisession-edit-value) - -(define-derived-mode multisession-edit-mode special-mode "Multisession" - "This mode lists all elements in the \"multisession\" database." - :interactive nil - (buffer-disable-undo) - (setq-local buffer-read-only t - truncate-lines t) - (setq tabulated-list-format - [("Package" 10) - ("Key" 30) - ("Value" 30)]) - (setq-local revert-buffer-function #'multisession-edit-mode--revert)) - -;;;###autoload -(defun list-multisession-values (&optional choose-storage) - "List all values in the \"multisession\" database. -If CHOOSE-STORAGE (interactively, the prefix), query for the -storage method to list." - (interactive "P") - (let ((storage - (if choose-storage - (intern (completing-read "Storage method: " '(sqlite files) nil t)) - multisession-storage))) - (pop-to-buffer (get-buffer-create (format "*Multisession %s*" storage))) - (multisession-edit-mode) - (setq-local multisession-storage storage) - (multisession-edit-mode--revert) - (goto-char (point-min)))) - -(defun multisession-edit-mode--revert (&rest _) - (let ((inhibit-read-only t) - (id (get-text-property (point) 'tabulated-list-id))) - (erase-buffer) - (tabulated-list-init-header) - (setq tabulated-list-entries - (mapcar (lambda (elem) - (list - (cons (car elem) (cadr elem)) - (vector (car elem) (cadr elem) - (string-replace "\n" "\\n" - (format "%s" (caddr elem)))))) - (multisession--backend-values multisession-storage))) - (tabulated-list-print t) - (goto-char (point-min)) - (when id - (when-let* ((match - (text-property-search-forward 'tabulated-list-id id t))) - (goto-char (prop-match-beginning match)))))) - -(defun multisession-delete-value (id) - "Delete the value at point." - (interactive (list (get-text-property (point) 'tabulated-list-id)) - multisession-edit-mode) - (unless id - (error "No value on the current line")) - (unless (yes-or-no-p "Really delete this item? ") - (user-error "Not deleting")) - (multisession--backend-delete multisession-storage - (make-multisession :package (car id) - :key (cdr id))) - (let ((inhibit-read-only t)) - (beginning-of-line) - (delete-region (point) (progn (forward-line 1) (point))))) - -(defun multisession-edit-value (id) - "Edit the value at point." - (interactive (list (get-text-property (point) 'tabulated-list-id)) - multisession-edit-mode) - (unless id - (error "No value on the current line")) - (let* ((object (or - ;; If the multisession variable already exists, use - ;; it (so that we update it). - (if-let (sym (intern-soft (cdr id))) - (and (boundp sym) (symbol-value sym)) - nil) - ;; Create a new object. - (make-multisession - :package (car id) - :key (cdr id) - :storage multisession-storage))) - (value (multisession-value object))) - (setf (multisession-value object) - (car (read-from-string - (read-string "New value: " (prin1-to-string value)))))) - (multisession-edit-mode--revert)) - -(provide 'jao-multisession) - -;;; multisession.el ends here diff --git a/lib/eos/jao-notify.el b/lib/eos/jao-notify.el index 941be36..c1efb58 100644 --- a/lib/eos/jao-notify.el +++ b/lib/eos/jao-notify.el @@ -14,7 +14,7 @@ (defvar jao-notify-use-messages nil) (defvar jao-notify-timeout 5000) -(defvar jao-notify-audio-icon (jao-data-file "music-player-icon.png")) +(defvar jao-notify-audio-icon nil) (declare-function notifications-notify "notifications") (declare-function alert "alert") diff --git a/lib/eos/jao-r2e.el b/lib/eos/jao-r2e.el deleted file mode 100644 index 81bbed6..0000000 --- a/lib/eos/jao-r2e.el +++ /dev/null @@ -1,233 +0,0 @@ -;;; jao-r2e.el --- List of rss2email subscriptions -*- lexical-binding: t; -*- - -;; Copyright (C) 2025, 2026 Jose Antonio Ortega Ruiz - -;; Author: Jose Antonio Ortega Ruiz <mail@jao.io> -;; Keywords: news - -;; 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/>. - -(require 'multisession) -(require 'jao-url) - -(autoload 'View-quit "view") -(autoload 'eww-view-source "eww") -(autoload 'jao-notmuch-subtags "jao-notmuch") - -(defvar jao-r2e-command "r2e") -(defvar jao-r2e-confirm-toggle nil) - -(defconst jao-r2e--buffer "*r2e*") -(defun jao-r2e--buffer () - (with-current-buffer (get-buffer-create jao-r2e--buffer) - (unless (derived-mode-p 'jao-r2e-mode) - (jao-r2e-mode)) - (current-buffer))) - -(defvar jao-r2e-mode-map - (let ((map (make-keymap))) - (suppress-keymap map) - (define-key map [?q] 'bury-buffer) - (define-key map [?n] 'next-line) - (define-key map [?p] 'previous-line) - (define-key map [?N] 'jao-r2e-next) - (define-key map [?P] 'jao-r2e-prev) - (define-key map [?g] 'jao-r2e-list) - (define-key map [?s] 'jao-r2e-subscribe) - (define-key map [?t] 'jao-r2e-toggle) - (define-key map [?D] 'jao-r2e-delete) - (define-key map [?u] 'jao-r2e-recover) - (define-key map [?y] 'jao-r2e-kill-url) - (define-key map [?x] 'jao-r2e-list-subscribed) - map)) - -;;;###autoload -(defun jao-r2e-mode () - "A very simple mode to show the output of r2e commands." - (interactive) - (kill-all-local-variables) - (buffer-disable-undo) - (use-local-map jao-r2e-mode-map) - ;; (setq-local font-lock-defaults '(jao-r2e-font-lock-keywords)) - (setq-local truncate-lines t) - (setq-local next-line-add-newlines nil) - (setq major-mode 'jao-r2e-mode) - (setq mode-name "r2e") - (read-only-mode 1)) - -(defun jao-r2e--do (things &optional buffer) - "Execute a r2e command THINGS in the given BUFFER." - (let ((b (or buffer (pop-to-buffer (jao-r2e--buffer))))) - (let ((inhibit-read-only t) - (cmd (format "%s %s" jao-r2e-command things))) - (unless buffer - (with-current-buffer b (delete-region (point-min) (point-max)))) - (with-temp-message (format "Running: %s ...." cmd) - (shell-command cmd b)) - (unless buffer (read-only-mode 1))))) - -(defconst jao-r2e--feed-rx - "^\\([0-9]+\\): \\[\\( \\|\\*\\)\\] \\([^ ]+\\) (\\(.+\\) -> \\(.+\\))") - -(defun jao-r2e--feed-at-point () - (beginning-of-line) - (when-let* ((m (looking-at jao-r2e--feed-rx))) - (list (match-string 1) - (match-string 3) - (string= "*" (match-string 2)) - (match-string 4) - (match-string 5)))) - -(defun jao-r2e () - (interactive) - (pop-to-buffer (jao-r2e--buffer)) - (when (looking-at-p "^$") - (jao-r2e-list))) - -(defun jao-r2e-list () - (interactive) - (jao-r2e--do "list")) - -(defun jao-r2e-list-subscribed (arg) - "Show only subscribed (unsubscribed with arg) feeds." - (interactive "P") - (jao-r2e-list) - (let ((inhibit-read-only t)) - (flush-lines (if arg ".*\\[\\*\\].*" ".*\\[ \\].*")))) - -(defun jao-r2e--srx (opp) - (when-let* ((f (jao-r2e--feed-at-point))) - (let ((a (if opp (not (caddr f)) (caddr f)))) - (format "^[0-9]+: \\[%s\\] " (if a "\\*" " "))))) - -(defun jao-r2e-next (opp) - "Next feed with the same (or opposite) status." - (interactive "P") - (when-let* ((rx (jao-r2e--srx opp))) - (next-line) - (when (re-search-forward rx nil t) - (beginning-of-line)))) - -(defun jao-r2e-prev (opp) - "Previous feed with the same (or opposite) status." - (interactive "P") - (when-let* ((rx (jao-r2e--srx opp))) - (when (re-search-backward rx nil t) - (beginning-of-line)))) - -(defun jao-r2e-kill-url () - "Copy as kill the URL of the feed at point." - (interactive) - (let ((url (cadddr (jao-r2e--feed-at-point)))) - (if (not url) - (error "No feed at point") - (kill-new url) - (message "%s" url)))) - -(defun jao-r2e-toggle () - (interactive) - (let ((f (jao-r2e--feed-at-point))) - (unless f (error "No feed at point")) - (let ((p (point)) - (no (car f)) - (name (cadr f)) - (act (if (caddr f) "pause" "unpause"))) - (when (or (not jao-r2e-confirm-toggle) - (yes-or-no-p (format "%s '%s'? " act name))) - (with-temp-buffer - (jao-r2e--do (format "%s %s" act no) (current-buffer))) - (jao-r2e-list) - (goto-char p))))) - -(define-multisession-variable jao-r2e-deleted-feeds '() - "List of rss2email feeds deleted at some point.") - -(defun jao-r2e--deleted () (multisession-value jao-r2e-deleted-feeds)) - -(defun jao-r2e-delete () - "Delete feed at point. Use `jao-r2e-recover' to undelete." - (interactive) - (let ((f (jao-r2e--feed-at-point))) - (unless f (error "No feed at point")) - (let ((p (point)) - (no (car f)) - (entry (cdr f))) - (when (yes-or-no-p (format "Delete feed '%s'" (car entry))) - (setf (multisession-value jao-r2e-deleted-feeds) - (cons entry (remove entry (jao-r2e--deleted)))) - (with-temp-buffer - (jao-r2e--do (format "delete %s" no) (current-buffer))) - (jao-r2e-list) - (goto-char p))))) - -(defun jao-r2e-recover () - (interactive) - (when (seq-empty-p (jao-r2e--deleted)) - (error "No feeds recoverable at this point.")) - (let* ((entries (jao-r2e--deleted)) - (feed (completing-read "Recover feed: " entries))) - (when-let* ((ps (assoc feed entries)) - (url (caddr ps)) - (mail (car (last ps))) - (cat (when (string-match "feeds\\.\\(.+\\)@localhost" mail) - (match-string 1 mail)))) - (jao-r2e-subscribe (list url feed) cat t) - (setf (multisession-value jao-r2e-deleted-feeds) (remove ps entries))))) - -(defun jao-r2e--find-url () - (save-excursion - (when (derived-mode-p 'w3m-mode 'eww-mode) - (if (fboundp 'w3m-view-source) (w3m-view-source) (eww-view-source))) - (goto-char (point-min)) - (when (re-search-forward - "type=\"application/\\(?:atom\\|rss\\)\\+xml\" +" nil t) - (let ((url (save-excursion - (when (re-search-forward - "href=\"\\([^\n\"]+\\)\"" nil t) - (match-string-no-properties 1)))) - (title (when (re-search-forward - "\\(?:title=\"\\([^\n\"]+\\)\" +\\)" nil t) - (match-string-no-properties 1)))) - (cond ((derived-mode-p 'w3m-view-mode) (w3m-view-source)) - ((string-match-p ".*\\*eww-source\\b.*" (buffer-name)) - (View-quit))) - (when url (cons url (or title ""))))))) - -(defun jao-r2e-subscribe (url &optional cat relist) - "Subscribe to a given RSS URL. If URL not given, look for it." - (interactive (list (or (jao-url-around-point) - (jao-r2e--find-url) - (read-string "Feed URL: ")))) - (let* ((url+title (ensure-list url)) - (url (car url+title)) - (title (cdr url+title))) - (unless url (error "No feeds found")) - (let ((url (if (string-match "^feed:" url) (substring url 5) url))) - (when (y-or-n-p (format "Subscribe to <%s>? " url)) - (let* ((name (read-string "Feed name: " title)) - (cats (cons "prog" (jao-notmuch-subtags "feeds"))) - (cat (completing-read "Category: " cats nil t cat)) - (sfmt (format "%%s add %s '%s' mail+feeds_%s@jao.io" name url cat)) - (subs )) - (with-temp-message "Subscribing..." - (shell-command-to-string (format sfmt "r2e")) - (when (not (string= jao-r2e-command "r2e")) - (shell-command-to-string (format sfmt jao-r2e-command)))) - (when (y-or-n-p "Retrieve feeds now? ") - (with-temp-message "Retrieving feed..." - (shell-command (format "%s run %s" jao-r2e-command name)))) - (when relist (jao-r2e-list))))))) - -(provide 'jao-r2e) -;;; jao-r2e.el ends here diff --git a/lib/eos/jao-shell.el b/lib/eos/jao-shell.el index 86bf46b..e13e07f 100644 --- a/lib/eos/jao-shell.el +++ b/lib/eos/jao-shell.el @@ -1,6 +1,6 @@ ;;; jao-shell.el --- shell utils -*- lexical-binding: t; -*- -;; Copyright (C) 2022 jao +;; Copyright (C) 2022, 2026 jao ;; Author: jao <mail@jao.io> ;; Keywords: shell @@ -59,7 +59,7 @@ (defun jao-shell-output (cmd handler) (with-temp-buffer (call-process-shell-command cmd nil (current-buffer)) - (beginning-of-buffer) + (goto-char (point-min)) (funcall handler))) (defun jao-shell-running-p (pr) (eq 0 (jao-shell-exec* t "pidof" pr))) diff --git a/lib/eos/jao-sleep.el b/lib/eos/jao-sleep.el index b047373..3b46031 100644 --- a/lib/eos/jao-sleep.el +++ b/lib/eos/jao-sleep.el @@ -1,6 +1,6 @@ ;;; jao-sleep.el --- Actions upon sleep/awake -*- lexical-binding: t; -*- -;; Copyright (C) 2020 jao +;; Copyright (C) 2020, 2026 jao ;; Author: jao <mail@jao.io> ;; Keywords: hardware @@ -25,7 +25,7 @@ (defvar jao-sleep-sleep-functions nil) (defvar jao-sleep-awake-functions nil) -(defvar jao-sleep--dbus-registration-object nil) +(defvar jao-sleep--dbus-sleep-registration-object nil) (defun jao-sleep--dbus-sleep-handler (sleep-start) (condition-case nil diff --git a/lib/eos/jao-tracking.el b/lib/eos/jao-tracking.el index 280e9fb..6ee04bd 100644 --- a/lib/eos/jao-tracking.el +++ b/lib/eos/jao-tracking.el @@ -87,11 +87,11 @@ (defvar jao-tracking--pipe (let ((name "/tmp/emacs.status")) (unless (file-exists-p name) - (shell-command (format "mkfifo %s" name name))) + (shell-command (format "mkfifo %s" name))) name)) (defun jao-tracking-set-log (v) - (when (member window-system '(x)) + (when (fboundp 'x-change-window-property) (x-change-window-property "_EMACS_LOG" v nil nil nil nil 0)) (if jao-wayland-enabled (let ((inhibit-message t)) diff --git a/lib/eos/jao-wayland.el b/lib/eos/jao-wayland.el index 9458ccb..e743eb0 100644 --- a/lib/eos/jao-wayland.el +++ b/lib/eos/jao-wayland.el @@ -18,6 +18,7 @@ ;; You should have received a copy of the GNU General Public License ;; along with this program. If not, see <https://www.gnu.org/licenses/>. +(require 'browse-url) (require 'jao-shell) (require 'jao-pdf) (require 'jao-tracking) |
