| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 |
|
|---|
| 25 |
|
|---|
| 26 |
|
|---|
| 27 |
|
|---|
| 28 |
|
|---|
| 29 |
|
|---|
| 30 |
(eval-when-compile |
|---|
| 31 |
(require 'cl) |
|---|
| 32 |
(require 'ring)) |
|---|
| 33 |
|
|---|
| 34 |
|
|---|
| 35 |
|
|---|
| 36 |
(defvar gnus-mouse-2 [mouse-2]) |
|---|
| 37 |
(defvar gnus-down-mouse-3 [down-mouse-3]) |
|---|
| 38 |
(defvar gnus-down-mouse-2 [down-mouse-2]) |
|---|
| 39 |
(defvar gnus-widget-button-keymap nil) |
|---|
| 40 |
(defvar gnus-mode-line-modified |
|---|
| 41 |
(if (or (featurep 'xemacs) |
|---|
| 42 |
(< emacs-major-version 20)) |
|---|
| 43 |
'("--**-" . "-----") |
|---|
| 44 |
'("**" "--"))) |
|---|
| 45 |
|
|---|
| 46 |
(eval-and-compile |
|---|
| 47 |
(autoload 'gnus-xmas-define "gnus-xmas") |
|---|
| 48 |
(autoload 'gnus-xmas-redefine "gnus-xmas") |
|---|
| 49 |
(autoload 'appt-select-lowest-window "appt") |
|---|
| 50 |
(autoload 'gnus-get-buffer-create "gnus") |
|---|
| 51 |
(autoload 'nnheader-find-etc-directory "nnheader")) |
|---|
| 52 |
|
|---|
| 53 |
(autoload 'smiley-region "smiley") |
|---|
| 54 |
|
|---|
| 55 |
(autoload 'message-text-with-property "message") |
|---|
| 56 |
|
|---|
| 57 |
(defun gnus-kill-all-overlays () |
|---|
| 58 |
"Delete all overlays in the current buffer." |
|---|
| 59 |
(let* ((overlayss (overlay-lists)) |
|---|
| 60 |
(buffer-read-only nil) |
|---|
| 61 |
(overlays (delq nil (nconc (car overlayss) (cdr overlayss))))) |
|---|
| 62 |
(while overlays |
|---|
| 63 |
(delete-overlay (pop overlays))))) |
|---|
| 64 |
|
|---|
| 65 |
|
|---|
| 66 |
|
|---|
| 67 |
(defun gnus-mule-max-width-function (el max-width) |
|---|
| 68 |
`(let* ((val (eval (, el))) |
|---|
| 69 |
(valstr (if (numberp val) |
|---|
| 70 |
(int-to-string val) val))) |
|---|
| 71 |
(if (> (length valstr) ,max-width) |
|---|
| 72 |
(truncate-string-to-width valstr ,max-width) |
|---|
| 73 |
valstr))) |
|---|
| 74 |
|
|---|
| 75 |
(eval-and-compile |
|---|
| 76 |
(defalias 'gnus-char-width |
|---|
| 77 |
(if (fboundp 'char-width) |
|---|
| 78 |
'char-width |
|---|
| 79 |
(lambda (ch) 1)))) |
|---|
| 80 |
|
|---|
| 81 |
(eval-and-compile |
|---|
| 82 |
(if (featurep 'xemacs) |
|---|
| 83 |
(gnus-xmas-define) |
|---|
| 84 |
(defvar gnus-mouse-face-prop 'mouse-face |
|---|
| 85 |
"Property used for highlighting mouse regions."))) |
|---|
| 86 |
|
|---|
| 87 |
(eval-when-compile |
|---|
| 88 |
(defvar gnus-tmp-unread) |
|---|
| 89 |
(defvar gnus-tmp-replied) |
|---|
| 90 |
(defvar gnus-tmp-score-char) |
|---|
| 91 |
(defvar gnus-tmp-indentation) |
|---|
| 92 |
(defvar gnus-tmp-opening-bracket) |
|---|
| 93 |
(defvar gnus-tmp-lines) |
|---|
| 94 |
(defvar gnus-tmp-name) |
|---|
| 95 |
(defvar gnus-tmp-closing-bracket) |
|---|
| 96 |
(defvar gnus-tmp-subject-or-nil) |
|---|
| 97 |
(defvar gnus-check-before-posting) |
|---|
| 98 |
(defvar gnus-mouse-face) |
|---|
| 99 |
(defvar gnus-group-buffer)) |
|---|
| 100 |
|
|---|
| 101 |
(defun gnus-ems-redefine () |
|---|
| 102 |
(cond |
|---|
| 103 |
((featurep 'xemacs) |
|---|
| 104 |
(gnus-xmas-redefine)) |
|---|
| 105 |
|
|---|
| 106 |
((featurep 'mule) |
|---|
| 107 |
|
|---|
| 108 |
|
|---|
| 109 |
|
|---|
| 110 |
|
|---|
| 111 |
|
|---|
| 112 |
|
|---|
| 113 |
|
|---|
| 114 |
|
|---|
| 115 |
|
|---|
| 116 |
|
|---|
| 117 |
|
|---|
| 118 |
|
|---|
| 119 |
|
|---|
| 120 |
|
|---|
| 121 |
|
|---|
| 122 |
|
|---|
| 123 |
|
|---|
| 124 |
|
|---|
| 125 |
(defvar gnus-summary-display-table nil |
|---|
| 126 |
"Display table used in summary mode buffers.") |
|---|
| 127 |
(defalias 'gnus-max-width-function 'gnus-mule-max-width-function) |
|---|
| 128 |
|
|---|
| 129 |
(when (boundp 'gnus-check-before-posting) |
|---|
| 130 |
(setq gnus-check-before-posting |
|---|
| 131 |
(delq 'long-lines |
|---|
| 132 |
(delq 'control-chars gnus-check-before-posting)))) |
|---|
| 133 |
|
|---|
| 134 |
(defun gnus-summary-line-format-spec () |
|---|
| 135 |
(insert gnus-tmp-unread gnus-tmp-replied |
|---|
| 136 |
gnus-tmp-score-char gnus-tmp-indentation) |
|---|
| 137 |
(put-text-property |
|---|
| 138 |
(point) |
|---|
| 139 |
(progn |
|---|
| 140 |
(insert |
|---|
| 141 |
gnus-tmp-opening-bracket |
|---|
| 142 |
(format "%4d: %-20s" |
|---|
| 143 |
gnus-tmp-lines |
|---|
| 144 |
(if (> (length gnus-tmp-name) 20) |
|---|
| 145 |
(truncate-string-to-width gnus-tmp-name 20) |
|---|
| 146 |
gnus-tmp-name)) |
|---|
| 147 |
gnus-tmp-closing-bracket) |
|---|
| 148 |
(point)) |
|---|
| 149 |
gnus-mouse-face-prop gnus-mouse-face) |
|---|
| 150 |
(insert " " gnus-tmp-subject-or-nil "\n"))))) |
|---|
| 151 |
|
|---|
| 152 |
(defun gnus-region-active-p () |
|---|
| 153 |
"Say whether the region is active." |
|---|
| 154 |
(and (boundp 'transient-mark-mode) |
|---|
| 155 |
transient-mark-mode |
|---|
| 156 |
(boundp 'mark-active) |
|---|
| 157 |
mark-active)) |
|---|
| 158 |
|
|---|
| 159 |
(defun gnus-mark-active-p () |
|---|
| 160 |
"Non-nil means the mark and region are currently active in this buffer." |
|---|
| 161 |
mark-active) |
|---|
| 162 |
|
|---|
| 163 |
(if (fboundp 'add-minor-mode) |
|---|
| 164 |
(defalias 'gnus-add-minor-mode 'add-minor-mode) |
|---|
| 165 |
(defun gnus-add-minor-mode (mode name map &rest rest) |
|---|
| 166 |
(set (make-local-variable mode) t) |
|---|
| 167 |
(unless (assq mode minor-mode-alist) |
|---|
| 168 |
(push `(,mode ,name) minor-mode-alist)) |
|---|
| 169 |
(unless (assq mode minor-mode-map-alist) |
|---|
| 170 |
(push (cons mode map) |
|---|
| 171 |
minor-mode-map-alist)))) |
|---|
| 172 |
|
|---|
| 173 |
(defun gnus-x-splash () |
|---|
| 174 |
"Show a splash screen using a pixmap in the current buffer." |
|---|
| 175 |
(interactive) |
|---|
| 176 |
(unless window-system |
|---|
| 177 |
(error "`gnus-x-splash' requires running on the window system")) |
|---|
| 178 |
(switch-to-buffer (gnus-get-buffer-create (if (or (gnus-alive-p) |
|---|
| 179 |
(interactive-p)) |
|---|
| 180 |
"*gnus-x-splash*" |
|---|
| 181 |
gnus-group-buffer))) |
|---|
| 182 |
(let ((inhibit-read-only t) |
|---|
| 183 |
(file (nnheader-find-etc-directory "images/gnus/x-splash" t)) |
|---|
| 184 |
pixmap fcw fch width height fringes sbars left yoffset top ls) |
|---|
| 185 |
(erase-buffer) |
|---|
| 186 |
(sit-for 0) |
|---|
| 187 |
(when (and file |
|---|
| 188 |
(ignore-errors |
|---|
| 189 |
(let ((coding-system-for-read 'raw-text) |
|---|
| 190 |
default-enable-multibyte-characters) |
|---|
| 191 |
(with-temp-buffer |
|---|
| 192 |
(insert-file-contents file) |
|---|
| 193 |
(goto-char (point-min)) |
|---|
| 194 |
(setq pixmap (read (current-buffer))))))) |
|---|
| 195 |
(setq fcw (float (frame-char-width)) |
|---|
| 196 |
fch (float (frame-char-height)) |
|---|
| 197 |
width (/ (car pixmap) fcw) |
|---|
| 198 |
height (/ (cadr pixmap) fch) |
|---|
| 199 |
fringes (if (fboundp 'window-fringes) |
|---|
| 200 |
(eval '(window-fringes)) |
|---|
| 201 |
'(10 11 nil)) |
|---|
| 202 |
sbars (frame-parameter nil 'vertical-scroll-bars)) |
|---|
| 203 |
(cond ((eq sbars 'right) |
|---|
| 204 |
(setq sbars |
|---|
| 205 |
(cons 0 (/ (or (frame-parameter nil 'scroll-bar-width) 14) |
|---|
| 206 |
fcw)))) |
|---|
| 207 |
(sbars |
|---|
| 208 |
(setq sbars |
|---|
| 209 |
(cons (/ (or (frame-parameter nil 'scroll-bar-width) 14) |
|---|
| 210 |
fcw) |
|---|
| 211 |
0))) |
|---|
| 212 |
(t |
|---|
| 213 |
(setq sbars '(0 . 0)))) |
|---|
| 214 |
(setq left (- (* (round (/ (1- (/ (+ (window-width) |
|---|
| 215 |
(car sbars) (cdr sbars) |
|---|
| 216 |
(/ (+ (or (car fringes) 0) |
|---|
| 217 |
(or (cadr fringes) 0)) |
|---|
| 218 |
fcw)) |
|---|
| 219 |
width)) |
|---|
| 220 |
2)) |
|---|
| 221 |
width) |
|---|
| 222 |
(car sbars) |
|---|
| 223 |
(/ (or (car fringes) 0) fcw)) |
|---|
| 224 |
yoffset (cadr (window-edges)) |
|---|
| 225 |
top (max 0 (- (* (max (if (and tool-bar-mode |
|---|
| 226 |
(not (featurep 'gtk)) |
|---|
| 227 |
(eq (frame-first-window) |
|---|
| 228 |
(selected-window))) |
|---|
| 229 |
1 0) |
|---|
| 230 |
(round (/ (1- (/ (+ (1- (window-height)) |
|---|
| 231 |
(* 2 yoffset)) |
|---|
| 232 |
height)) |
|---|
| 233 |
2))) |
|---|
| 234 |
height) |
|---|
| 235 |
yoffset)) |
|---|
| 236 |
ls (/ (or line-spacing 0) fch) |
|---|
| 237 |
height (max 0 (- height ls))) |
|---|
| 238 |
(cond ((>= (- top ls) 1) |
|---|
| 239 |
(insert |
|---|
| 240 |
(propertize |
|---|
| 241 |
" " |
|---|
| 242 |
'display `(space :width 0 :ascent 100)) |
|---|
| 243 |
"\n" |
|---|
| 244 |
(propertize |
|---|
| 245 |
" " |
|---|
| 246 |
'display `(space :width 0 :height ,(- top ls 1) :ascent 100)) |
|---|
| 247 |
"\n")) |
|---|
| 248 |
((> (- top ls) 0) |
|---|
| 249 |
(insert |
|---|
| 250 |
(propertize |
|---|
| 251 |
" " |
|---|
| 252 |
'display `(space :width 0 :height ,(- top ls) :ascent 100)) |
|---|
| 253 |
"\n"))) |
|---|
| 254 |
(if (and (> width 0) (> left 0)) |
|---|
| 255 |
(insert (propertize |
|---|
| 256 |
" " |
|---|
| 257 |
'display `(space :width ,left :height ,height :ascent 0))) |
|---|
| 258 |
(setq width (+ width left))) |
|---|
| 259 |
(when (> width 0) |
|---|
| 260 |
(insert (propertize |
|---|
| 261 |
" " |
|---|
| 262 |
'display `(space :width ,width :height ,height :ascent 0) |
|---|
| 263 |
'face `(gnus-splash :stipple ,pixmap)))) |
|---|
| 264 |
(goto-char (if (<= (- top ls) 0) (1- (point)) (point-min))) |
|---|
| 265 |
(redraw-frame (selected-frame)) |
|---|
| 266 |
(sit-for 0)))) |
|---|
| 267 |
|
|---|
| 268 |
|
|---|
| 269 |
|
|---|
| 270 |
(defun gnus-image-type-available-p (type) |
|---|
| 271 |
(and (fboundp 'image-type-available-p) |
|---|
| 272 |
(image-type-available-p type) |
|---|
| 273 |
(if (fboundp 'display-images-p) |
|---|
| 274 |
(display-images-p) |
|---|
| 275 |
t))) |
|---|
| 276 |
|
|---|
| 277 |
(defun gnus-create-image (file &optional type data-p &rest props) |
|---|
| 278 |
(let ((face (plist-get props :face))) |
|---|
| 279 |
(when face |
|---|
| 280 |
(setq props (plist-put props :foreground (face-foreground face))) |
|---|
| 281 |
(setq props (plist-put props :background (face-background face)))) |
|---|
| 282 |
(apply 'create-image file type data-p props))) |
|---|
| 283 |
|
|---|
| 284 |
(defun gnus-put-image (glyph &optional string category) |
|---|
| 285 |
(let ((point (point))) |
|---|
| 286 |
(insert-image glyph (or string " ")) |
|---|
| 287 |
(put-text-property point (point) 'gnus-image-category category) |
|---|
| 288 |
(unless string |
|---|
| 289 |
(put-text-property (1- (point)) (point) |
|---|
| 290 |
'gnus-image-text-deletable t)) |
|---|
| 291 |
glyph)) |
|---|
| 292 |
|
|---|
| 293 |
(defun gnus-remove-image (image &optional category) |
|---|
| 294 |
(dolist (position (message-text-with-property 'display)) |
|---|
| 295 |
(when (and (equal (get-text-property position 'display) image) |
|---|
| 296 |
(equal (get-text-property position 'gnus-image-category) |
|---|
| 297 |
category)) |
|---|
| 298 |
(put-text-property position (1+ position) 'display nil) |
|---|
| 299 |
(when (get-text-property position 'gnus-image-text-deletable) |
|---|
| 300 |
(delete-region position (1+ position)))))) |
|---|
| 301 |
|
|---|
| 302 |
(provide 'gnus-ems) |
|---|
| 303 |
|
|---|
| 304 |
|
|---|
| 305 |
|
|---|
| 306 |
|
|---|