diff options
author | Manoj Srivastava <srivasta@debian.org> | 2008-02-08 23:16:36 +0000 |
---|---|---|
committer | Manoj Srivastava <srivasta@debian.org> | 2008-02-08 23:16:36 +0000 |
commit | c201b4e334aecbe25e815a9423563fc5e18b33ee (patch) | |
tree | 9cf4f8a24425da09cb16ceb3918f783b1da1f545 /contrib | |
parent | 8370db611d9bec3831ab42ee3eed77022b64d597 (diff) |
Imported vm-8.0.7-522
Imported vm-8.0.7-522
into srivasta@debian.org--lenny/vm--upstream--8.0
git-archimport-id: srivasta@debian.org--lenny/vm--upstream--8.0--patch-1
Diffstat (limited to 'contrib')
-rw-r--r-- | contrib/attempted-locking.diff | 105 | ||||
-rw-r--r-- | contrib/vm-blueman.el | 119 | ||||
-rw-r--r-- | contrib/vm-mime-display-internal-application.el | 204 | ||||
-rw-r--r-- | contrib/vm-mime.el-w3m.patch | 134 |
4 files changed, 562 insertions, 0 deletions
diff --git a/contrib/attempted-locking.diff b/contrib/attempted-locking.diff new file mode 100644 index 0000000..93f59cf --- /dev/null +++ b/contrib/attempted-locking.diff @@ -0,0 +1,105 @@ +# Bazaar revision bundle v0.8 +# +# message: +# first shot at improving the locking. +# committer: rpgoldman@real-time.com +# date: Sun 2006-10-08 18:19:49.986000061 -0500 + +=== modified file vm-folder.el +--- vm-folder.el ++++ vm-folder.el +@@ -2993,6 +2993,8 @@ + buffer-file-name))) + (vm-get-spooled-mail nil)) + (progn ++ ;; if we've got new mail, then lock the buffer.... ++ (lock-buffer) + ;; don't move the message pointer unless the folder + ;; was empty. + (if (and (null vm-message-pointer) +@@ -3185,6 +3187,9 @@ + vm-default-folder-permission-bits)) + (save-buffer prefix)) + (and oldmodebits (set-default-file-modes oldmodebits)))) ++ ;; if the folder's been locked (it should have been), then ++ ;; unlock it. ++ (unlock-buffer) + (vm-set-buffer-modified-p nil) + ;; clear the modified flag in virtual folders if all the + ;; real buffers associated with them are unmodified. +@@ -3630,6 +3635,9 @@ + mail-waiting )))) + + (defun vm-get-spooled-mail (&optional interactive) ++ "Gets new spooled mail according to the folder-access method. ++Returns a list of new messages \(not sure what the data type of ++\"message\" is in this context\)." + (if vm-block-new-mail + (error "Can't get new mail until you save this folder.")) + (cond ((eq vm-folder-access-method 'pop) + +=== modified file vm-startup.el +--- vm-startup.el ++++ vm-startup.el +@@ -153,7 +153,7 @@ + (coding-system-for-read + (vm-line-ending-coding-system))) + (message "Reading %s..." file) +- (prog1 (find-file-noselect file) ++ (prog1 (vm-find-file-noselect file) + ;; update folder history + (let ((item (or remote-spec folder + vm-primary-inbox))) +@@ -223,6 +223,8 @@ + ;; If the buffer's not modified then we know that there can be no + ;; messages in the folder that are not on disk. + (or (buffer-modified-p) (setq vm-messages-not-on-disk 0)) ++ ;; if the buffer's been modified, it should be locked... ++ (and (buffer-modified-p) (lock-buffer)) + (setq first-time (not (eq major-mode 'vm-mode)) + preserve-auto-save-file (and buffer-file-name + (not (buffer-modified-p)) +@@ -393,6 +395,33 @@ + (if (not (input-pending-p)) + (message totals-blurb))))))) + ++;;; helper function ++(defun vm-find-file-noselect (filename) ++ (let* ((buffer (find-file-noselect filename)) ++ (lock (file-locked-p filename))) ++ (cond ((null lock) ++ ;; not locked, no worries ++ buffer) ++ ((eq lock t) ++ ;; this xemacs has the buffer locked. I don't believe that ++ ;; this should be a problem, either. Unless it means that ++ ;; I've introduced a bug, and not properly unlocked things... ++ (warn "Buffer is locked by this emacs. Unexpected -- please report.") ++ buffer) ++ (t ++ ;; the lock value is the name of the locking user ++ (let ((query-result (ask-user-about-lock ++ filename lock))) ++ (cond ((eq query-result t) ++ ;; steal the lock ++ buffer) ++ ((null query-result) ++ (save-excursion ++ (set-buffer buffer) ++ (setq buffer-read-only t)) ++ (message "Opening folder read-only.") ++ buffer))))))) ++ + ;;;###autoload + (defun vm-other-frame (&optional folder read-only) + "Like vm, but run in a newly created frame." + +# revision id: rpgoldman@real-time.com-20061008231949-1bd9467b25ca41b8 +# sha1: 9ee06c49007ffdec241f9f0f4206dda2e327015f +# inventory sha1: afad72f633b5cbae416178d327931a735786f2f0 +# parent ids: +# hack@robf.de-20061005191950-d7498e730daa5855 +# base id: hack@robf.de-20061005191950-d7498e730daa5855 +# properties: +# branch-nick: vm + diff --git a/contrib/vm-blueman.el b/contrib/vm-blueman.el new file mode 100644 index 0000000..ac3eacd --- /dev/null +++ b/contrib/vm-blueman.el @@ -0,0 +1,119 @@ +;From: blueman <NOSPAM@nospam.com> +;Subject: Function to fit displayed mime images to width +;Newsgroups: gnu.emacs.vm.info +;Date: Tue, 12 Dec 2006 18:07:44 GMT + +;Was going through some old code and would like to share this helpful +;function.. + +;; Stretch/Shrink mime image to fit exactly in frame width. +;; The shrink functionality is particularly helpful since images displayed +;; by emacs look wacked when they extend past a line width +(defun vm-mime-fitwidth-image (extent) +"Stretch/Shrink mime image to fit exactly in frame width (JJK)." + (let* ((layout (vm-extent-property extent 'vm-mime-layout)) + (blob (get (vm-mm-layout-cache layout) + 'vm-mime-display-internal-image-xxxx)) + dims tempfile factor) + ;; Emacs 19 uses a different layout cache than XEmacs or Emacs 21+. + ;; The cache blob is a list in that case. + (if (consp blob) + (setq tempfile (car blob)) + (setq tempfile blob)) + (setq dims (vm-get-image-dimensions tempfile)) + (setq factor (/ (float (* (1- (frame-width)) (frame-char-width))) (car dims))) + (vm-mime-frob-image-xxxx extent + "-scale" + (concat (int-to-string (* factor (car dims))) + "x" + (int-to-string (* factor (nth 1 dims))))))) + +;; Functionality to add above function to standard attachment menu +(add-hook 'vm-menu-setup-hook + (lambda () + (require 'easymenu) + (easy-menu-add-item vm-menu-fsfemacs-image-menu + nil + ["Fit to width" + (vm-mime-run-display-function-at-point 'vm-mime-fitwidth-image) + (stringp vm-imagemagick-convert-program)] + "4x Larger" ) + (easy-menu-add-item vm-menu-fsfemacs-attachment-menu + nil + ["Save attachment..." + (vm-mime-run-display-function-at-point + 'vm-mime-send-body-to-file) + t ] + "Set Content Disposition..." ) + (easy-menu-add-item vm-menu-fsfemacs-attachment-menu + nil + ["Delete attachment..." + (vm-delete-mime-object) + t ] + "Set Content Disposition..." ) + (easy-menu-add-item vm-menu-fsfemacs-attachment-menu + nil + ["Attach to message..." + (call-interactively 'vm-mime-attach-object-from-message) + t ] + "Set Content Disposition..." ) + (easy-menu-add-item vm-menu-fsfemacs-attachment-menu + nil + ["Display as Ascii" + (vm-mime-run-display-function-at-point + 'vm-mime-display-body-as-text) + t ] + "Set Content Disposition..." ) + (easy-menu-add-item vm-menu-fsfemacs-attachment-menu + nil + ["Pipe to Command" + (vm-mime-run-display-function-at-point + 'vm-mime-pipe-body-to-queried-command-discard-output) + t ] + "Set Content Disposition..." ) + )) + + + +;From: blueman <NOSPAM@nospam.com> +;Subject: Function to retrieve mail via fetchmail from emacs/vm +;Newsgroups: gnu.emacs.vm.info +;Date: Tue, 12 Dec 2006 18:31:57 GMT + +;Was going through some old code and would like to share this helpful +;function.. + +;Note this runs the users local fetchmail process as configured by +;~/.fetchmailrc +(defun vm-fetchmail () +"*Fetch mail asynchronously from remote server (JJK)" + (interactive) + (cond + ((file-executable-p vm-fetchmail-function) + (set-process-sentinel + (start-process "Fetchmail" "*Fetchmail*" vm-fetchmail-function) + 'vm-fetchmail-sentinel) + (message "Fetching new mail...")) + (t (error "Error: Fetchmail not found on system!")))) + +(defvar vm-fetchmail-function "/usr/bin/fetchmail" +"Function used to fetch remote mail (JJK)") + +(defun vm-fetchmail-sentinel (process status) + (beep t) + (setq status (substring status -2 -1)) + (message "Finished fetching... %s" + (if (string= status "d") "*New mail*" + (setq status (string-to-number status)) + (cond + ((= status 1) "No new mail") + ((= status 2) "Error opening socket") + ((= status 3) "User authentication failed") + ((= status 4) "Fatal protocol error") + ((= status 5) "Syntax error") + ((= status 6) "Bad permissions on run control file") + ((= status 7) "Error condition reported by server") + ((= status 8) "Client-side exclusion error") + ((= status 9) "Lock busy") + (t "Other error"))))) + diff --git a/contrib/vm-mime-display-internal-application.el b/contrib/vm-mime-display-internal-application.el new file mode 100644 index 0000000..de898f0 --- /dev/null +++ b/contrib/vm-mime-display-internal-application.el @@ -0,0 +1,204 @@ +;;; vm-mime-display-internal-application.el --- Display application attachments +;;; -*-unibyte: t; coding: iso-8859-1;-*- + +;; Copyright © 2004 Kevin Rodgers + +;; Author: Kevin Rodgers <ihs_4664@yahoo.com> +;; Created: 11 Jun 2004 +;; Version: $Revision: 1.5 $ +;; Keywords: mail, mime +;; RCS: $Id: vm-mime-display-internal-application.el,v 1.5 2004/07/14 23:29:04 kevinr Exp $ + +;; This program is free software; you can redistribute it and/or +;; modify it under the terms of the GNU General Public License as +;; published by the Free Software Foundation; either version 2 of +;; the License, or (at your option) any later version. + +;; This program is distributed in the hope that it will be +;; useful, but WITHOUT ANY WARRANTY; without even the implied +;; warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +;; PURPOSE. See the GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public +;; License along with this program; if not, write to the Free +;; Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, +;; MA 02111-1307 USA + +;;; Commentary: + +;; VM does not provide a way to display additional MIME media types +;; internally. This file defines a new user variable to control which +;; application/* subtypes can be displayed within Emacs: +;; C-h v vm-mime-internal-application-subtypes +;; +;; It also defines user commands to register a subtype and to install +;; all registered subtypes as internally displayable applications: +;; M-x vm-mime-register-internal-application +;; M-x vm-mime-install-internal-applications +;; +;; Usage: +;; (load-library "vm-mime-display-internal-application") +;; (vm-mime-register-internal-application "foo" t) ; to run foo-mode +;; (vm-mime-register-internal-application "bar" 'baz-mode) +;; (vm-mime-install-internal-applications) + +;;; Code: + +(require 'vm) + +(defvar vm-mime-internal-application-subtypes + ;; see http://www.iana.org/assignments/media-types/application/ + '(("emacs-lisp" . t) ; lisp-mode.el + ("tar" . t) ; tar-mode.el + ("arc" . archive-mode) ; arc-mode.el + ("lzh" . archive-mode) ; arc-mode.el + ("zip" . archive-mode) ; arc-mode.el + ("zoo" . archive-mode) ; arc-mode.el + ;; For file-name-handler subtypes, let find-file-noselect -> + ;; after-find-file -> (normal-mode t) choose the mode. Specify + ;; ignore instead of normal-mode for these subtypes, so that the + ;; optional FIND-FILE argument doesn't override enable-local-variables. + ("gzip" . ignore) ; jka-compr.el + ("bzip2" . ignore) ; jka-compr.el + ("compress" . ignore)) ; jka-compr.el + "List of MIME \"application/*\" subtypes that should be displayed internally. + +Each (SUBTYPE . MODE) element maps the \"applicaton/SUBTYPE\" MIME +content type to the major MODE used to display it. Both the MODE and +`vm-mime-display-internal-application/SUBTYPE' functions must be +defined. + +If MODE is t, SUBTYPE-mode is used to display \"application/SUBTYPE\" +attachments.") + +(defvar vm-mime-internal-application-x-subtypes nil + "*If non-nil, display application/x-SUBTYPE attachments the same as application/SUBTYPE attachments. +See `vm-mime-internal-application-subtypes'.") + +(defadvice vm-mime-can-display-internal (after application/xxxx activate + compile) + "Respect `vm-mime-internal-application-subtypes'." + (or ad-return-value + (setq ad-return-value + (let* ((layout (ad-get-arg 0)) + (type (car (vm-mm-layout-type layout))) + (subtype (if (vm-mime-types-match "application" type) + (substring type (1+ (match-end 0))))) + (mode (if subtype + (vm-mime-can-display-internal-application + subtype)))) + (if mode + (let ((charset (or (vm-mime-get-parameter layout "charset") + "us-ascii"))) + (or (vm-mime-charset-internally-displayable-p charset) + (vm-mime-can-convert-charset charset)))))))) + +(defun vm-mime-can-display-internal-application (subtype) + "Return the Emacs mode for displaying \"application/SUBTYPE\" MIME objects." + (catch 'major-mode + (let ((subtypes vm-mime-internal-application-subtypes) + mode) + (while subtypes + (if (or (equal subtype (car (car subtypes))) + (and vm-mime-internal-application-x-subtypes + (equal subtype (concat "x-" (car (car subtypes)))))) + (cond ((and (eq (cdr (car subtypes)) 't) + (fboundp (setq mode (intern (concat subtype "-mode"))))) + (throw 'major-mode mode)) + ((fboundp (setq mode (cdr (car subtypes)))) + (throw 'major-mode mode)))) + (setq subtypes (cdr subtypes))) + nil))) + +(defun vm-mime-display-internal-application/xxxx (layout) + "Display LAYOUT in its own buffer." + ;; see vm-mime-display-external-generic + (let* ((tempfile (or (get (vm-mm-layout-cache layout) + 'vm-mime-display-internal-application/xxxx) + (let ((suffix + (or (vm-mime-extract-filename-suffix layout) + (vm-mime-find-filename-suffix-for-type + layout))) + (filename + (or (vm-mime-get-disposition-parameter layout + "filename") + (vm-mime-get-parameter layout "name")))) + (vm-make-tempfile-name suffix filename)))) + (type (car (vm-mm-layout-type layout))) + (subtype (if (vm-mime-types-match "application" type) + (substring type (1+ (match-end 0)))))) + (vm-mime-send-body-to-file layout nil tempfile) + (vm-register-message-garbage-files (list tempfile)) + (put (vm-mm-layout-cache layout) + 'vm-mime-display-internal-application/xxxx + tempfile) + (let* ((inhibit-local-variables t) + (enable-local-variables nil) + (enable-local-eval nil) + (pop-up-frames vm-mutable-frames) + (pop-up-windows vm-mutable-windows) + (mode (vm-mime-can-display-internal-application subtype))) + (pop-to-buffer + (find-file-noselect tempfile)) ; (with-auto-compression-mode ...) + (or (eq major-mode mode) + (funcall mode)) +;; (when pop-up-frames +;; (set-window-dedicated-p (selected-window) t)) + (cond (pop-up-frames + (add-hook 'kill-buffer-hook 'delete-frame t t)) + (pop-up-windows + (add-hook 'kill-buffer-hook 'delete-window t t)))))) + +(defun vm-mime-register-internal-application (subtype mode) + "Add (SUBTYPE . MODE) to `vm-mime-internal-application-subtypes'. +Also define the `vm-mime-display-internal-application/SUBTYPE' and +`vm-mime-display-button-application/SUBTYPE' functions. + +If MODE is nil, just define the functions." + (interactive + (let* ((subtype (completing-read "Subtype: " + vm-mime-internal-application-subtypes)) + (subtype-mode (fboundp (intern (concat subtype "-mode")))) + (completion-ignore-case nil) + (mode (intern (completing-read (if subtype-mode + "Mode: (default t) " + "Mode: ") + obarray + (lambda (s) + (and (fboundp s) + (string-match "-mode\\'" + (symbol-name s)))) + t nil nil (if subtype-mode "t"))))) + (or (eq mode 't) + (fboundp mode) ; i.e. (equal (symbol-name mode) "") + (error "Undefined mode: %s" mode)) ; (unintern mode) + (list subtype mode))) + (if mode + (setq vm-mime-internal-application-subtypes + (cons (cons subtype mode) vm-mime-internal-application-subtypes))) + (let ((internal + (intern (concat "vm-mime-display-internal-application/" subtype))) + (button + (intern (concat "vm-mime-display-button-application/" subtype)))) + (defalias internal 'vm-mime-display-internal-application/xxxx) + (fset button (lambda (layout) + (vm-mime-display-button-xxxx layout nil))) + (if vm-mime-internal-application-x-subtypes + (progn + (defalias (intern (concat "vm-mime-display-internal-application/x-" + subtype)) + internal) + (defalias (intern (concat "vm-mime-display-button-application/x-" + subtype)) + button))))) + +(defun vm-mime-install-internal-applications () + "Define display and button functions for each registered subtype. +See `vm-mime-internal-application-subtypes'." + (interactive) + (let ((subtypes vm-mime-internal-application-subtypes)) + (while subtypes + (vm-mime-register-internal-application (car (car subtypes)) nil) + (setq subtypes (cdr subtypes))))) + +;;; vm-mime-display-internal-application.el ends here diff --git a/contrib/vm-mime.el-w3m.patch b/contrib/vm-mime.el-w3m.patch new file mode 100644 index 0000000..88fa068 --- /dev/null +++ b/contrib/vm-mime.el-w3m.patch @@ -0,0 +1,134 @@ +=== modified file 'vm-mime.el' +--- vm-mime.el 2006-08-21 21:17:05 +0000 ++++ vm-mime.el 2006-09-18 23:09:23 +0000 +@@ -2060,49 +2060,87 @@ + (defun vm-mime-display-internal-text (layout) + (vm-mime-display-internal-text/plain layout)) + ++(autoload 'w3m-region "w3m" "Render region using w3m") ++ ++(defcustom vm-mime-renderer-for-text/html 'w3 ++ "The HTML renderer to use for internal display. ++W3M is usually faster and better than W3." ++ :group 'vm ++ :type '(choice (const w3) ++ (const w3m))) ++ ++(defun vm-mime-display-internal-text/html-with-w3m (start end) ++ (save-restriction ++ (narrow-to-region start end) ++ (let ((w3m-safe-url-regexp "\\`cid:") ++ w3m-force-redisplay) ++ (goto-char (point-max)) ++ (insert-before-markers "z") ++ (w3m-region (point-min) (1- (point-max))) ++ (goto-char (point-max)) ++ (delete-char -1)) ++ ++ (when (and (boundp 'w3m-minor-mode-map) w3m-minor-mode-map) ++ (add-text-properties (point-min) (point-max) ++ (list 'keymap w3m-minor-mode-map))))) ++ ++(defun vm-mime-display-internal-text/html-with-w3 (start end) ++ ;; w3-region apparently deletes all the text in the ++ ;; region and then insert new text. This makes the ++ ;; end == start. The fix is to move the end marker ++ ;; forward with a placeholder character so that when ++ ;; w3-region delete all the text, end will still be ++ ;; ahead of the insertion point and so will be moved ++ ;; forward when the new text is inserted. We'll ++ ;; delete the placeholder afterward. ++ (goto-char end) ++ (insert-before-markers "z") ++ (w3-region start (1- end)) ++ (goto-char end) ++ (delete-char -1)) ++ + (defun vm-mime-display-internal-text/html (layout) +- (if (and (fboundp 'w3-region) +- vm-mime-use-w3-for-text/html) +- (condition-case error-data +- (let ((buffer-read-only nil) +- (start (point)) +- (charset (or (vm-mime-get-parameter layout "charset") +- "us-ascii")) +- end buffer-size) +- (message "Inlining text/html, be patient...") +- (vm-mime-insert-mime-body layout) +- (setq end (point-marker)) +- (vm-mime-transfer-decode-region layout start end) +- (vm-mime-charset-decode-region charset start end) +- ;; w3-region apparently deletes all the text in the +- ;; region and then insert new text. This makes the +- ;; end == start. The fix is to move the end marker +- ;; forward with a placeholder character so that when +- ;; w3-region delete all the text, end will still be +- ;; ahead of the insertion point and so will be moved +- ;; forward when the new text is inserted. We'll +- ;; delete the placeholder afterward. +- (goto-char end) +- (insert-before-markers "z") +- (w3-region start (1- end)) +- (goto-char end) +- (delete-char -1) +- ;; remove read-only text properties +- (let ((inhibit-read-only t)) +- (remove-text-properties start end '(read-only nil))) +- (goto-char end) +- (message "Inlining text/html... done") +- t ) +- (error (vm-set-mm-layout-display-error +- layout +- (format "Inline HTML display failed: %s" +- (prin1-to-string error-data))) +- (message "%s" (vm-mm-layout-display-error layout)) +- (sleep-for 2) +- nil )) +- (vm-set-mm-layout-display-error layout "Need W3 to inline HTML") +- (message "%s" (vm-mm-layout-display-error layout)) +- nil )) ++ (let ((render-func ++ (cond ((eq vm-mime-renderer-for-text/html 'w3m) ++ 'vm-mime-display-internal-text/html-with-w3m) ++ ((eq vm-mime-renderer-for-text/html 'w3) ++ 'vm-mime-display-internal-text/html-with-w3) ++ (t ++ (vm-set-mm-layout-display-error ++ layout ++ (concat "Inline HTML display failed: function " ++ (symbol-name vm-mime-inline-render-function-for-text/html) ++ " not found. Please bind a valid function to vm-mime-inline-render-function-for-text/html.")) ++ (message "%s" (vm-mm-layout-display-error layout)) ++ nil)))) ++ (if (fboundp render-func) ++ (condition-case error-data ++ (let ((buffer-read-only nil) ++ (start (point)) ++ (charset (or (vm-mime-get-parameter layout "charset") ++ "us-ascii")) ++ end buffer-size) ++ (message "Inlining text/html, be patient...") ++ (vm-mime-insert-mime-body layout) ++ (setq end (point-marker)) ++ (vm-mime-transfer-decode-region layout start end) ++ (vm-mime-charset-decode-region charset start end) ++ ++ (funcall render-func start end) ++ ++ ;; remove read-only text properties ++ (let ((inhibit-read-only t)) ++ (remove-text-properties start end '(read-only nil))) ++ (goto-char end) ++ (message "Inlining text/html... done") ++ t ) ++ (error (vm-set-mm-layout-display-error ++ layout ++ (format "Inline HTML display failed: %s" ++ (prin1-to-string error-data))) ++ (message "%s" (vm-mm-layout-display-error layout)) ++ (sleep-for 2) ++ nil )))))) + + (defun vm-mime-display-internal-text/plain (layout &optional no-highlighting) + (let ((start (point)) end need-conversion + |