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 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 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
|