comparison lisp/mh-e/mh-xface.el @ 68520:6a7173abcf59

* mh-acros.el (mh-defun-compat, mh-defmacro-compat): Add name argument since compatibility functions should have our package prefix (mh-) by Emacs convention and to avoid messing up checks for the same functions in other packages. Use explicit argument instead of forming name by adding mh-e prefix so that one can grep and find the definition. * mh-alias.el (mh-alias-local-users, mh-alias-reload) (mh-alias-expand, mh-alias-minibuffer-confirm-address): Use mh-assoc-string instead of assoc-string. * mh-compat.el (assoc-string): Rename to mh-assoc-string. (mh-mail-abbrev-make-syntax-table, mh-url-hexify-string): Move here from mh-utils.el. (mh-display-completion-list): Move here from mh-comp.el. (mh-face-foreground, mh-face-background): Move here from mh-xface.el. (mh-write-file-functions): Move here from mh-folder.el * mh-folder.el (mh-write-file-functions-compat): Move to mh-compat.el and rename to mh-write-file-functions. (mh-folder-mode): Use the new name. * mh-gnus.el (gnus-local-map-property): Rename to mh-gnus-local-map-property. (mm-merge-handles): Rename to mh-mm-merge-handles. (mm-set-handle-multipart-parameter): Rename to mh-mm-set-handle-multipart-parameter. (mm-inline-text-vcard): Rename to mh-mm-inline-text-vcard. (mm-possibly-verify-or-decrypt): Rename to mh-mm-possibly-verify-or-decrypt. (mm-handle-multipart-ctl-parameter): Rename to mh-mm-handle-multipart-ctl-parameter. (mm-readable-p): Rename to mh-mm-readable-p. (mm-long-lines-p): Rename to mh-mm-long-lines-p. (mm-keep-viewer-alive-p): Rename to mh-mm-keep-viewer-alive-p. (mm-destroy-parts): Rename to mh-mm-destroy-parts. (mm-uu-dissect-text-parts): Rename to mh-mm-uu-dissect-text-parts. (mml-minibuffer-read-disposition): Rename to mh-mml-minibuffer-read-disposition. * mh-identity.el (mh-identity-field-handler): Use mh-assoc-string instead of assoc-string. * mh-mime.el (mh-mm-inline-media-tests, mh-mm-inline-message) (mh-mime-display, mh-mime-display-security) (mh-insert-mime-button, mh-insert-mime-security-button) (mh-handle-set-external-undisplayer) (mh-mime-security-press-button, mh-mime-security-show-details) (mh-mml-attach-file, mh-mime-cleanup) (mh-destroy-postponed-handles): Use new mh-* names for compatibility functions. * mh-utils.el (mail-abbrev-make-syntax-table): Move to mh-compat.el and rename to mh-mail-abbrev-make-syntax-table. (mh-beginning-of-word): Use the new name. (mh-get-field): Delete ancient alias. * mh-xface.el (mh-face-foreground-compat): Move to mh-compat.el and rename to mh-face-foreground (mh-face-background-compat): Move to mh-compat.el and rename to mh-face-background. (mh-face-display-function): Use the new names. (mh-x-image-url-cache-canonicalize): Use mh-url-hexify-string instead of url-hexify-string. (url-unreserved-chars): Move to mh-compat.el and rename to mh-url-unreserved-chars. (url-hexify-string): Move to mh-compat.el and rename to mh-url-hexify-string.
author Bill Wohler <wohler@newt.com>
date Tue, 31 Jan 2006 20:46:15 +0000
parents 4bd450a8dbe2
children d81780942bb8
comparison
equal deleted inserted replaced
68519:bf46ace1ce4e 68520:6a7173abcf59
56 "Display X-Face." 56 "Display X-Face."
57 (when (and window-system mh-show-use-xface-flag 57 (when (and window-system mh-show-use-xface-flag
58 (or mh-decode-mime-flag mh-mhl-format-file 58 (or mh-decode-mime-flag mh-mhl-format-file
59 mh-clean-message-header-flag)) 59 mh-clean-message-header-flag))
60 (funcall mh-show-xface-function))) 60 (funcall mh-show-xface-function)))
61
62 (defmacro mh-face-foreground-compat (face &optional frame inherit)
63 "Return the foreground color name of FACE, or nil if unspecified.
64 See documentation for `face-foreground' for a description of the
65 arguments FACE, FRAME, and INHERIT.
66
67 Calls `face-foreground' correctly in older environments. Versions
68 of Emacs prior to version 22 lacked an INHERIT argument which
69 when t tells `face-foreground' to consider an inherited value for
70 the foreground if the face does not define one itself."
71 (if (>= emacs-major-version 22)
72 `(face-foreground ,face ,frame ,inherit)
73 `(face-foreground ,face ,frame)))
74
75 (defmacro mh-face-background-compat(face &optional frame inherit)
76 "Return the background color name of face, or nil if unspecified.
77 See documentation for `back-foreground' for a description of the
78 arguments FACE, FRAME, and INHERIT.
79
80 Calls `face-background' correctly in older environments. Versions
81 of Emacs prior to version 22 lacked an INHERIT argument which
82 when t tells `face-background' to consider an inherited value for
83 the background if the face does not define one itself."
84 (if (>= emacs-major-version 22)
85 `(face-background ,face ,frame ,inherit)
86 `(face-background ,face ,frame)))
87 61
88 ;; Shush compiler. 62 ;; Shush compiler.
89 (eval-when-compile 63 (eval-when-compile
90 (mh-do-in-xemacs (defvar default-enable-multibyte-characters))) 64 (mh-do-in-xemacs (defvar default-enable-multibyte-characters)))
91 65
118 (mh-x-image-url-display url) 92 (mh-x-image-url-display url)
119 (mh-funcall-if-exists 93 (mh-funcall-if-exists
120 insert-image (create-image 94 insert-image (create-image
121 raw type t 95 raw type t
122 :foreground 96 :foreground
123 (mh-face-foreground-compat 'mh-show-xface nil t) 97 (mh-face-foreground 'mh-show-xface nil t)
124 :background 98 :background
125 (mh-face-background-compat 'mh-show-xface nil t)) 99 (mh-face-background 'mh-show-xface nil t))
126 " "))) 100 " ")))
127 ;; XEmacs 101 ;; XEmacs
128 (mh-do-in-xemacs 102 (mh-do-in-xemacs
129 (cond 103 (cond
130 ((eq type 'url) 104 ((eq type 'url)
384 (setq mh-x-image-cache-directory directory))) 358 (setq mh-x-image-cache-directory directory)))
385 359
386 (defun mh-x-image-url-cache-canonicalize (url) 360 (defun mh-x-image-url-cache-canonicalize (url)
387 "Canonicalize URL. 361 "Canonicalize URL.
388 Replace the ?/ character with a ?! character and append .png. 362 Replace the ?/ character with a ?! character and append .png.
389 Also replaces special characters with `url-hexify-string' since 363 Also replaces special characters with `mh-url-hexify-string'
390 not all characters, such as :, are legal within Windows 364 since not all characters, such as :, are legal within Windows
391 filenames. See URL `http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/fs/naming_a_file.asp'." 365 filenames. See URL
366 `http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/fs/naming_a_file.asp'."
392 (format "%s/%s.png" mh-x-image-cache-directory 367 (format "%s/%s.png" mh-x-image-cache-directory
393 (url-hexify-string 368 (mh-url-hexify-string
394 (with-temp-buffer 369 (with-temp-buffer
395 (insert url) 370 (insert url)
396 (mh-replace-string "/" "!") 371 (mh-replace-string "/" "!")
397 (buffer-string))))) 372 (buffer-string)))))
398
399 ;; Copy of constant from url-util.el in Emacs 22; needed by Emacs 21.
400 (if (not (boundp 'url-unreserved-chars))
401 (defconst url-unreserved-chars
402 '(
403 ?a ?b ?c ?d ?e ?f ?g ?h ?i ?j ?k ?l ?m ?n ?o ?p ?q ?r ?s ?t ?u ?v ?w ?x ?y ?z
404 ?A ?B ?C ?D ?E ?F ?G ?H ?I ?J ?K ?L ?M ?N ?O ?P ?Q ?R ?S ?T ?U ?V ?W ?X ?Y ?Z
405 ?0 ?1 ?2 ?3 ?4 ?5 ?6 ?7 ?8 ?9
406 ?- ?_ ?. ?! ?~ ?* ?' ?\( ?\))
407 "A list of characters that are _NOT_ reserved in the URL spec.
408 This is taken from RFC 2396."))
409
410 (mh-defun-compat url-hexify-string (str)
411 "Escape characters in a string.
412 This is a copy of the function of the same name from url-util.el
413 in Emacs 22; needed by Emacs 21."
414 (mapconcat
415 (lambda (char)
416 ;; Fixme: use a char table instead.
417 (if (not (memq char url-unreserved-chars))
418 (if (> char 255)
419 (error "Hexifying multibyte character %s" str)
420 (format "%%%02X" char))
421 (char-to-string char)))
422 str ""))
423 373
424 (defun mh-x-image-get-download-state (file) 374 (defun mh-x-image-get-download-state (file)
425 "Check the state of FILE by following any symbolic links." 375 "Check the state of FILE by following any symbolic links."
426 (unless (file-exists-p mh-x-image-cache-directory) 376 (unless (file-exists-p mh-x-image-cache-directory)
427 (call-process "mkdir" nil nil nil mh-x-image-cache-directory)) 377 (call-process "mkdir" nil nil nil mh-x-image-cache-directory))