Mercurial > hg > xemacs
diff my-news.el @ 45:65ea96008fe0
hacked up some stuff to get rid of useless safelinks.outlook... link wrappers,
acquired use-text-not-html from mail-extras
author | Henry S. Thompson <ht@inf.ed.ac.uk> |
---|---|
date | Wed, 20 Dec 2023 17:59:49 +0000 |
parents | eee08de75336 |
children | 95ba4cc6ffe4 |
line wrap: on
line diff
--- a/my-news.el Wed Dec 20 17:58:34 2023 +0000 +++ b/my-news.el Wed Dec 20 17:59:49 2023 +0000 @@ -390,8 +390,6 @@ (define-key message-mode-map [(control meta q)] 'add-quaker) (remove-hook 'message-mode-hook 'message-mode-fun1)) -(defvar ht-gnus-just-read nil) - (defun ht-catchup-and-next-unseen () (interactive) (when (gnus-summary-catchup nil t nil 'fast) @@ -411,7 +409,8 @@ (defun ht-gnus-pers-refresh (n) (interactive "p") (let ((gn (concat "nnml+ht:pers-" - (format-time-string "%Y-%m" (current-time))))) + (format-time-string "%Y-%m" (current-time)))) + (jr ht-gnus-just-read)) (gnus-group-get-new-news) (let ((nn (gnus-number-of-unseen-articles-in-group gn))) (gnus-group-goto-group gn) @@ -426,8 +425,8 @@ (gnus-group-read-group nil t))) (t (goto-char (point-min)) (ht-next-with-unseen 1)))) - (message "%s" ht-gnus-just-read)) - ) + (message "read: %s" ht-gnus-just-read) + )) (defun no-select () (if (member gnus-newsgroup-name no-select-groups) @@ -666,11 +665,6 @@ (interactive "p") (ht-next-with-unseen (- n))) -(defun ht-gnus-note-save-to-group () - (let ((g (caar group-art))) - (if (not (member g ht-gnus-just-read)) - (setq ht-gnus-just-read (cons g ht-gnus-just-read))))) - (defvar ht-stash-directory (concat my-mail-dir "/stash/")) (defun ht-save-part (handle n) @@ -791,4 +785,57 @@ (fset 'orig-message-send-and-exit (symbol-function 'message-send-and-exit)) (fset 'message-send-and-exit (symbol-function 'my-message-send-and-exit)))) +;; see message-citation-line-function in message.el +(defun safe-citation () + (use-text-not-html) + (when message-reply-headers + (let ((from (mail-header-from message-reply-headers))) + (cond ((string-match "^\"?\\([^\"]*\\)\"? <.*>$" from) + (insert (match-string 1 from) " writes:\n\n")) + ((string-match "^\\([^<@]*\\)@" from) + (insert (match-string 1 from) " writes:\n\n")) + (t + (insert "[anon] writes:\n\n")))))) + +(defun use-text-not-html (&optional clear) + (when (and (if clear (looking-at "<html") + (looking-at "> <html")) + (bufferp (get-buffer "*Shell Command Output*"))) + ;; replace HTML only with result of my HTML filter + (delete-region (point)(mark t)) + (insert-buffer "*Shell Command Output*") + (when (looking-at "piping") + (kill-entire-line) + (indent-rigidly (point) (mark t) -3) + (if (not clear) + (submerge-region (point) (mark t))))) + ) + +(setq message-citation-line-function (function safe-citation)) + + +(defvar safelink_pat "https://[a-z0-9.]*safelinks.protection.outlook.com/\\?url=\\(https?%3A%2F%2F[^&<>\"]*\\)[^\"<> ]*") + +(require 'url) + +(defvar url-ok-chars (nconc + '(?/ ?& ?% ?+ ?? ?= ?: ?; + ?# + ) + url-unreserved-chars)) + +(defun unsafelink () + ;; Thanks to Iain Murray for + ;; /public/homepages/imurray2/web/code/hacks/unsafelink + (let ((url-unreserved-chars url-ok-chars)) + (while (re-search-forward safelink_pat nil t) + (let ((res (match-string 1))) + (replace-match "") + ;; unhexify uses regex, so trashes match-string :-( + (insert (url-hexify-string (url-unhex-string res))) + )) + )) + +(add-hook 'gnus-article-prepare-hook 'unsafelink) + (provide 'my-news)