mail-lib / mail-utils.el

Diff from to


 	    (substring s (match-beginning 3) (match-end 3)) " "
 	    (mail-rfc822-time-zone time))))
+(defun mail-y-or-n-p (question &rest text)
+  "Ask QUESTION, displaying the rest of the arguments as strings in a buffer."
+  (setq text (mail-flatten-list text))
+  (save-window-excursion
+    (save-excursion
+      (with-output-to-temp-buffer " *SMTP information message*"
+	(set-buffer " *SMTP information message*")
+	(fundamental-mode)		; for Emacs 20.4+
+	(mapcar 'princ text)
+	(goto-char (point-min))))
+    (y-or-n-p question)))
+(defun mail-flatten-list (list)
+  "Return a new, flat list that contains all elements of LIST.
+\(mail-flatten-list '(1 (2 3 (4 5 (6))) 7))
+=> (1 2 3 4 5 6 7)"
+  (cond ((consp list)
+	 (apply 'append (mapcar 'mail-flatten-list list)))
+	(list
+	 (list list))))
+(defun mail-check-safe-charset ()
+  "Check that buffer contain characters that will be safely encoded."
+  (if (featurep 'mule)
+      (let ((bad-charsets (set-difference
+			   (find-charset-region (point-min) (point-max))
+			   '(ascii latin-iso8859-1 control-1))))
+	(when bad-charsets
+	  (or (mail-y-or-n-p 
+	       "Your message contain invalid characters. Continue? "
+	       "You're trying to send a message that contain characters\nin the following character set:\n\n" (mapconcat 'symbol-name bad-charsets ", ") "\n\nThese characters cannot be send without proper encoding.  Please\nconsider using a MIME enabled mail composer (such as `message').\nContinuing is likely to cause mail corruption.")
+	      (error "Message contain invalid character"))))))
 (provide 'mail-utils)
 ;;; mail-utils.el ends here
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.