annotate mdn-extras.el @ 67:a9b2a2335782 default tip

make setting advert whiten as well if needed, handle naked div in replying to html
author Henry S Thompson <ht@inf.ed.ac.uk>
date Sat, 21 Dec 2024 20:00:43 +0000
parents 06827fc8ae79
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
20
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
1 ;; Last edited: Thu Jun 11 14:04:02 1992
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
2 ;; stub for henry's mail reading and diary maintenance tools
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
3 ;; Copyright (C) 1990 Henry S. Thompson
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
4 ;; Edit history: made diary-setup do (update-default-diary nil) instead of t
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
5
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
6 ;; This file is part of GNU Emacs.
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
7
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
8 ;; GNU Emacs is distributed in the hope that it will be useful,
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
9 ;; but WITHOUT ANY WARRANTY. No author or distributor
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
10 ;; accepts responsibility to anyone for the consequences of using it
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
11 ;; or for whether it serves any particular purpose or works at all,
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
12 ;; unless he says so in writing. Refer to the GNU Emacs General Public
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
13 ;; License for full details.
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
14
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
15 ;; Everyone is granted permission to copy, modify and redistribute
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
16 ;; GNU Emacs, but only under the conditions described in the
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
17 ;; GNU Emacs General Public License. A copy of this license is
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
18 ;; supposed to have been given to you along with GNU Emacs so you
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
19 ;; can know your rights and responsibilities. It should be in a
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
20 ;; file named COPYING. Among other things, the copyright notice
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
21 ;; and this notice must be preserved on all copies.
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
22
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
23 (provide 'mdn-extras)
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
24
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
25 ;; get my sendmail, on way or another
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
26
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
27 (if (featurep 'sendmail)
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
28 ;; already loaded - overwrite
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
29 (site-caseq
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
30 (parc (load "~hthompso/emacs/shared/sendmail"))))
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
31
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
32 (setq command-switch-alist
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
33 (nconc command-switch-alist '(("-m" . ht-mail-setup)
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
34 ("-mail" . ht-mail-setup)
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
35 ("-d" . ht-diary-setup)
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
36 ("-diary" . ht-diary-setup))))
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
37
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
38 (setq command-switch-alist
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
39 (nconc command-switch-alist '(("-n" . ht-news-setup)
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
40 ("-news" . ht-news-setup))))
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
41
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
42 (autoload 'gnus "gnus" "read news" t)
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
43
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
44 (defvar ht-default-config nil "saved window configuration after startup")
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
45 (defvar ht-back-config (current-window-configuration)
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
46 "saved window configuration from before ^Cw/^C^w")
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
47
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
48 (defun ht-mail-setup (&optional arg)
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
49 "set up my mail reading and do it"
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
50 (interactive)
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
51 (require 'mail-extras) ; mail stuff
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
52 (if (featurep 'gnus) ; in case gnus is around
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
53 (split-window-vertically))
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
54 (rmail)
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
55 (setq ht-default-config (current-window-configuration)))
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
56
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
57 (defun ht-diary-setup (&optional arg)
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
58 "diary setup"
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
59 (interactive)
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
60 (require 'diary)
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
61 (update-default-diary nil) ; set up standard config.
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
62 (if (featurep 'rmail)
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
63 (if (featurep 'gnus) ; in case gnus is around
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
64 (progn (other-window 1)
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
65 (split-window)
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
66 (other-window 1)
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
67 (switch-to-buffer (get-file-buffer rmail-file-name)))
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
68 (switch-to-buffer (get-file-buffer rmail-file-name))
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
69 (other-window 1)
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
70 (split-window)
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
71 (other-window 1)
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
72 (switch-to-buffer (save-excursion (set-buffer (get-file-buffer
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
73 ht-diary-file-name))
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
74 rmail-summary-buffer))
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
75 (other-window 1)))
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
76 (setq ht-default-config (current-window-configuration)))
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
77
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
78 (defun ht-news-setup (&optional arg)
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
79 "set up my GNUS and do it"
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
80 (interactive)
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
81 (require 'my-news) ; GNUS stuff
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
82 (if (featurep 'rmail)
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
83 (split-window-vertically))
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
84 (gnus)
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
85 (setq ht-default-config (current-window-configuration)))
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
86
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
87 (defun default-config ()
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
88 "restore screen to default config"
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
89 (interactive)
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
90 (setq ht-back-config (current-window-configuration))
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
91 (set-window-configuration ht-default-config))
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
92
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
93 (defun back-config ()
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
94 (interactive)
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
95 (set-window-configuration (prog1 ht-back-config
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
96 (setq ht-back-config
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
97 (current-window-configuration)))))
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
98
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
99 (global-set-key "\C-cw" 'default-config)
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
100
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
101 (global-set-key "\C-c\C-w" 'back-config)
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
102
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
103 (setq mail-custom-fields
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
104 '(("To" (fill-addr-field (local-field-var to "")) "\C-t")
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
105 ("Subject" (ht-subj-with-reply) "\C-s")))
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
106
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
107 (defun ht-subj-with-reply ()
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
108 (let ((subj (local-field-var subject ""))
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
109 (irt (local-field-var in-reply-to)))
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
110 (if (and in-reply-to
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
111 (not (string-match "^Re:" subj)))
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
112 (concat "Re: " subj)
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
113 subj)))
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
114
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
115
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
116 ;;; Henry's special double update hack
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
117
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
118 (add-hook 'rmail-mode-hook 'rmail-mode-fun3)
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
119
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
120 (defun get-mail-news-and ()
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
121 "update both if both present"
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
122 (interactive)
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
123 (rmail-get-new-mail)
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
124 (let (nw)
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
125 (setq nw (get-buffer "*Newsgroup*"))
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
126 (if nw
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
127 (save-window-excursion
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
128 (pop-to-buffer nw)
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
129 (gnus-group-get-new-news)))))
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
130
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
131 ;;; rescued from old rmail
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
132 ;;; hacked to cope with differences between e19 and lucid
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
133 (defun ht-rmail-delete-forward (&optional backward)
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
134 "Delete this message and move to next nondeleted one.
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
135 Deleted messages stay in the file until the \\[rmail-expunge] command is given.
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
136 With prefix argument, delete and move backward.
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
137 If there is no nondeleted message to move to
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
138 in the preferred or specified direction, move in the other direction."
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
139 (interactive "P")
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
140 (rmail-set-attribute "deleted" t)
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
141 (if (or
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
142 (string-match "Lucid" emacs-version)
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
143 (and (boundp 'emacs-minor-version)
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
144 (> emacs-minor-version 19) ; not sure where pblm was fixed
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
145 ; certainly by 28
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
146 ))
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
147 (if (not (rmail-next-undeleted-message (if backward -1 1)))
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
148 (if (rmail-previous-undeleted-message (if backward -1 1))
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
149 (message "") ; override the stupid one
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
150 ))
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
151 (if (rmail-next-undeleted-message (if backward -1 1))
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
152 (if (not (rmail-previous-undeleted-message (if backward -1 1)))
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
153 (message "")))))
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
154
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
155 (defun rmail-mode-fun4 ()
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
156 (setq buffer-auto-save-file-name nil)
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
157 (make-variable-buffer-local 'backup-inhibited)
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
158 (setq backup-inhibited t))
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
159
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
160 (defun rmail-mode-fun3 ()
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
161 (define-key rmail-mode-map "G" 'get-mail-news-and)
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
162 (define-key rmail-mode-map "d" 'ht-rmail-delete-forward)
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
163 (remove-hook 'rmail-mode-hook 'rmail-mode-fun3)
06827fc8ae79 *** empty log message ***
ht
parents:
diff changeset
164 (add-hook 'rmail-mode-hook 'rmail-mode-fun4 t))