Mercurial > emacs
changeset 105867:00c0adbb54a9
* mh-thread.el (mh-thread-set-tables):
* mh-speed.el (mh-folder-speedbar-menu-items, mh-speed-stealth-update):
(mh-speed-extract-folder-name, mh-speed-parse-flists-output):
(mh-speed-invalidate-map, mh-speed-add-folder):
* mh-show.el (mh-invalidate-show-buffer, mh-show-sequence-menu):
* mh-seq.el (mh-list-sequences):
* mh-search.el (mh-index-execute-commands, mh-index-add-to-sequence)
(mh-index-delete-from-sequence, mh-index-update-maps):
* mh-scan.el (mh-msg-num-width):
* mh-print.el (mh-ps-spool-buffer):
* mh-mime.el (mh-mime-save-parts, mh-handle-set-external-undisplayer)
(mh-file-mime-type):
* mh-letter.el (mh-yank-cur-msg):
* mh-funcs.el (mh-list-folders, mh-pipe-msg, mh-store-msg)
(mh-store-buffer):
* mh-folder.el (mh-modify, mh-visit-folder, mh-write-msg-to-file)
(mh-prompt-for-refile-folder):
* mh-e.el (mh-exec-cmd, mh-exec-cmd-error, mh-exec-cmd-daemon)
(mh-handle-process-error, mh-variant-info):
* mh-comp.el (mh-forward):
* mh-alias.el (mh-alias-local-users, mh-alias-which-file-has-alias):
(mh-alias-add-alias-to-file): Use with-current-buffer.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Thu, 05 Nov 2009 21:04:59 +0000 |
parents | 3367f0022cf2 |
children | b4d1d7858370 |
files | lisp/mh-e/ChangeLog lisp/mh-e/mh-alias.el lisp/mh-e/mh-comp.el lisp/mh-e/mh-e.el lisp/mh-e/mh-folder.el lisp/mh-e/mh-funcs.el lisp/mh-e/mh-letter.el lisp/mh-e/mh-mime.el lisp/mh-e/mh-print.el lisp/mh-e/mh-scan.el lisp/mh-e/mh-search.el lisp/mh-e/mh-seq.el lisp/mh-e/mh-show.el lisp/mh-e/mh-speed.el lisp/mh-e/mh-thread.el |
diffstat | 15 files changed, 74 insertions(+), 85 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/mh-e/ChangeLog Thu Nov 05 21:01:32 2009 +0000 +++ b/lisp/mh-e/ChangeLog Thu Nov 05 21:04:59 2009 +0000 @@ -1,3 +1,28 @@ +2009-11-05 Stefan Monnier <monnier@iro.umontreal.ca> + + * mh-thread.el (mh-thread-set-tables): + * mh-speed.el (mh-folder-speedbar-menu-items, mh-speed-stealth-update): + (mh-speed-extract-folder-name, mh-speed-parse-flists-output): + (mh-speed-invalidate-map, mh-speed-add-folder): + * mh-show.el (mh-invalidate-show-buffer, mh-show-sequence-menu): + * mh-seq.el (mh-list-sequences): + * mh-search.el (mh-index-execute-commands, mh-index-add-to-sequence) + (mh-index-delete-from-sequence, mh-index-update-maps): + * mh-scan.el (mh-msg-num-width): + * mh-print.el (mh-ps-spool-buffer): + * mh-mime.el (mh-mime-save-parts, mh-handle-set-external-undisplayer) + (mh-file-mime-type): + * mh-letter.el (mh-yank-cur-msg): + * mh-funcs.el (mh-list-folders, mh-pipe-msg, mh-store-msg) + (mh-store-buffer): + * mh-folder.el (mh-modify, mh-visit-folder, mh-write-msg-to-file) + (mh-prompt-for-refile-folder): + * mh-e.el (mh-exec-cmd, mh-exec-cmd-error, mh-exec-cmd-daemon) + (mh-handle-process-error, mh-variant-info): + * mh-comp.el (mh-forward): + * mh-alias.el (mh-alias-local-users, mh-alias-which-file-has-alias): + (mh-alias-add-alias-to-file): Use with-current-buffer. + 2009-11-04 Stefan Monnier <monnier@iro.umontreal.ca> * mh-e.el: Load mh-loaddefs during compilation as well.
--- a/lisp/mh-e/mh-alias.el Thu Nov 05 21:01:32 2009 +0000 +++ b/lisp/mh-e/mh-alias.el Thu Nov 05 21:04:59 2009 +0000 @@ -135,8 +135,7 @@ "Return an alist of local users from /etc/passwd. Exclude all aliases already in `mh-alias-alist' from \"ali\"" (let (passwd-alist) - (save-excursion - (set-buffer (get-buffer-create mh-temp-buffer)) + (with-current-buffer (get-buffer-create mh-temp-buffer) (erase-buffer) (cond ((eq mh-alias-local-users t) @@ -394,8 +393,7 @@ (defun mh-alias-which-file-has-alias (alias file-list) "Return the name of writable file which defines ALIAS from list FILE-LIST." - (save-excursion - (set-buffer (get-buffer-create mh-temp-buffer)) + (with-current-buffer (get-buffer-create mh-temp-buffer) (let ((the-list file-list) (found)) (while the-list @@ -491,8 +489,7 @@ folder name hint when filing messages." (if (not file) (setq file (mh-alias-insert-file alias))) - (save-excursion - (set-buffer (find-file-noselect file)) + (with-current-buffer (find-file-noselect file) (goto-char (point-min)) (let ((alias-search (concat alias ":")) (letter)
--- a/lisp/mh-e/mh-comp.el Thu Nov 05 21:01:32 2009 +0000 +++ b/lisp/mh-e/mh-comp.el Thu Nov 05 21:04:59 2009 +0000 @@ -473,8 +473,7 @@ (mh-read-draft "" draft-name nil))))) (let (orig-from orig-subject) - (save-excursion - (set-buffer (get-buffer-create mh-temp-buffer)) + (with-current-buffer (get-buffer-create mh-temp-buffer) (erase-buffer) (insert-file-contents fwd-msg-file) (setq orig-from (mh-get-header-field "From:"))
--- a/lisp/mh-e/mh-e.el Thu Nov 05 21:01:32 2009 +0000 +++ b/lisp/mh-e/mh-e.el Thu Nov 05 21:04:59 2009 +0000 @@ -506,8 +506,7 @@ The side effects are what is desired. Any output is assumed to be an error and is shown to the user. The output is not read or parsed by MH-E." - (save-excursion - (set-buffer (get-buffer-create mh-log-buffer)) + (with-current-buffer (get-buffer-create mh-log-buffer) (let* ((initial-size (mh-truncate-log-buffer)) (start (point)) (args (mh-list-to-string args))) @@ -526,8 +525,7 @@ "In environment ENV, execute mh-command COMMAND with ARGS. ENV is nil or a string of space-separated \"var=value\" elements. Signals an error if process does not complete successfully." - (save-excursion - (set-buffer (get-buffer-create mh-temp-buffer)) + (with-current-buffer (get-buffer-create mh-temp-buffer) (erase-buffer) (let ((process-environment process-environment)) ;; XXX: We should purge the list that split-string returns of empty @@ -547,8 +545,7 @@ `set-process-filter' for more details of FILTER. ARGS are passed to COMMAND as command line arguments." - (save-excursion - (set-buffer (get-buffer-create mh-log-buffer)) + (with-current-buffer (get-buffer-create mh-log-buffer) (mh-truncate-log-buffer)) (let* ((process-connection-type nil) (process (apply 'start-process @@ -650,9 +647,8 @@ (insert (if (integerp status) (format "%s: exit code %d\n" command status) (format "%s: %s\n" command status))) - (save-excursion - (let ((error-message (buffer-substring (point-min) (point-max)))) - (set-buffer (get-buffer-create mh-log-buffer)) + (let ((error-message (buffer-substring (point-min) (point-max)))) + (with-current-buffer (get-buffer-create mh-log-buffer) (mh-truncate-log-buffer) (insert error-message))) (error "%s failed, check buffer %s for error message" @@ -743,9 +739,8 @@ (defun mh-variant-info (dir) "Return MH variant found in DIR, or nil if none present." - (save-excursion - (let ((tmp-buffer (get-buffer-create mh-temp-buffer))) - (set-buffer tmp-buffer) + (let ((tmp-buffer (get-buffer-create mh-temp-buffer))) + (with-current-buffer tmp-buffer (cond ((mh-variant-mh-info dir)) ((mh-variant-nmh-info dir))
--- a/lisp/mh-e/mh-folder.el Thu Nov 05 21:01:32 2009 +0000 +++ b/lisp/mh-e/mh-folder.el Thu Nov 05 21:04:59 2009 +0000 @@ -840,8 +840,8 @@ ;; Invalidate the show buffer if it is showing the same message that is ;; to be edited. (when (and (buffer-live-p (get-buffer mh-show-buffer)) - (equal (save-excursion (set-buffer mh-show-buffer) - buffer-file-name) + (equal (with-current-buffer mh-show-buffer + buffer-file-name) msg-filename)) (mh-invalidate-show-buffer)) @@ -1237,9 +1237,8 @@ (current-buffer (current-buffer)) (threaded-view-flag mh-show-threads-flag)) (delete-other-windows) - (save-excursion - (when (get-buffer folder) - (set-buffer folder) + (when (get-buffer folder) + (with-current-buffer folder (setq threaded-view-flag (memq 'unthread mh-view-ops)))) (when index-data (mh-make-folder folder) @@ -1289,8 +1288,7 @@ (output-file (mh-expand-file-name file))) (setq mh-last-destination (list 'write file (if no-header 'no-header)) mh-last-destination-write mh-last-destination) - (save-excursion - (set-buffer (get-buffer-create mh-temp-buffer)) + (with-current-buffer (get-buffer-create mh-temp-buffer) (erase-buffer) (insert-file-contents msg-file-to-output) (goto-char (point-min)) @@ -1824,8 +1822,7 @@ "Destination" (let ((refile-file (ignore-errors (mh-msg-filename (mh-get-msg-num t))))) (if (null refile-file) "" - (save-excursion - (set-buffer (get-buffer-create mh-temp-buffer)) + (with-current-buffer (get-buffer-create mh-temp-buffer) (erase-buffer) (insert-file-contents refile-file) (or (and mh-default-folder-for-message-function
--- a/lisp/mh-e/mh-funcs.el Thu Nov 05 21:01:32 2009 +0000 +++ b/lisp/mh-e/mh-funcs.el Thu Nov 05 21:04:59 2009 +0000 @@ -145,8 +145,7 @@ (interactive) (let ((temp-buffer mh-folders-buffer)) (with-output-to-temp-buffer temp-buffer - (save-excursion - (set-buffer temp-buffer) + (with-current-buffer temp-buffer (erase-buffer) (message "Listing folders...") (mh-exec-cmd-output "folders" t (if mh-recursive-folders-flag @@ -246,8 +245,7 @@ (list (read-string "Shell command on message: ") current-prefix-arg)) (let ((msg-file-to-pipe (mh-msg-filename (mh-get-msg-num t))) (message-directory default-directory)) - (save-excursion - (set-buffer (get-buffer-create mh-temp-buffer)) + (with-current-buffer (get-buffer-create mh-temp-buffer) (erase-buffer) (insert-file-contents msg-file-to-pipe) (goto-char (point-min)) @@ -293,8 +291,7 @@ (read-file-name "Store message in directory: " udir udir nil)))) (let ((msg-file-to-store (mh-msg-filename (mh-get-msg-num t)))) - (save-excursion - (set-buffer (get-buffer-create mh-temp-buffer)) + (with-current-buffer (get-buffer-create mh-temp-buffer) (erase-buffer) (insert-file-contents msg-file-to-store) (mh-store-buffer directory)))) @@ -332,8 +329,7 @@ (setq uudecode-filename (buffer-substring (point) (progn (end-of-line) (point))))))) - (save-excursion - (set-buffer (get-buffer-create mh-log-buffer)) + (with-current-buffer (get-buffer-create mh-log-buffer) (setq log-begin (mh-truncate-log-buffer)) (if (not (file-directory-p store-directory)) (progn @@ -350,8 +346,7 @@ (if (equal (call-process-region sh-start (point-max) command nil mh-log-buffer t) 0) - (save-excursion - (set-buffer mh-log-buffer) + (with-current-buffer mh-log-buffer (insert "\n(mh-store finished)\n")) (error "Error occurred during execution of %s" command)))))
--- a/lisp/mh-e/mh-letter.el Thu Nov 05 21:01:32 2009 +0000 +++ b/lisp/mh-e/mh-letter.el Thu Nov 05 21:04:59 2009 +0000 @@ -706,9 +706,9 @@ and `mh-ins-buf-prefix' is not inserted." (interactive) (if (and mh-sent-from-folder - (save-excursion (set-buffer mh-sent-from-folder) mh-show-buffer) - (save-excursion (set-buffer mh-sent-from-folder) - (get-buffer mh-show-buffer)) + (with-current-buffer mh-sent-from-folder mh-show-buffer) + (with-current-buffer mh-sent-from-folder + (get-buffer mh-show-buffer)) mh-sent-from-msg) (let ((to-point (point)) (to-buffer (current-buffer)))
--- a/lisp/mh-e/mh-mime.el Thu Nov 05 21:01:32 2009 +0000 +++ b/lisp/mh-e/mh-mime.el Thu Nov 05 21:04:59 2009 +0000 @@ -410,8 +410,7 @@ (message "No directory specified") (if (equal nil mh-mime-save-parts-default-directory) (setq mh-mime-save-parts-directory directory)) - (save-excursion - (set-buffer (get-buffer-create mh-log-buffer)) + (with-current-buffer (get-buffer-create mh-log-buffer) (cd directory) (setq mh-mime-save-parts-directory directory) (let ((initial-size (mh-truncate-log-buffer))) @@ -1073,8 +1072,7 @@ (let ((new-handle (copy-sequence handle))) (mm-handle-set-undisplayer new-handle function) (mm-handle-set-undisplayer handle nil) - (save-excursion - (set-buffer folder) + (with-current-buffer folder (push new-handle (mh-mime-handles (mh-buffer-data))))) (mm-handle-set-undisplayer handle function))) @@ -1729,9 +1727,8 @@ (file-readable-p filename))) nil) ;no file or not readable, ditto (t - (save-excursion - (let ((tmp-buffer (get-buffer-create mh-temp-buffer))) - (set-buffer tmp-buffer) + (let ((tmp-buffer (get-buffer-create mh-temp-buffer))) + (with-current-buffer tmp-buffer (unwind-protect (progn (call-process "file" nil '(t nil) nil "-b" "-i"
--- a/lisp/mh-e/mh-print.el Thu Nov 05 21:01:32 2009 +0000 +++ b/lisp/mh-e/mh-print.el Thu Nov 05 21:04:59 2009 +0000 @@ -105,8 +105,7 @@ (defun mh-ps-spool-buffer (buffer) "Spool BUFFER." - (save-excursion - (set-buffer buffer) + (with-current-buffer buffer (let ((ps-print-color-p mh-ps-print-color-option) (ps-left-header (list
--- a/lisp/mh-e/mh-scan.el Thu Nov 05 21:01:32 2009 +0000 +++ b/lisp/mh-e/mh-scan.el Thu Nov 05 21:04:59 2009 +0000 @@ -451,8 +451,7 @@ (or mh-progs (mh-find-path)) (let ((tmp-buffer (get-buffer-create mh-temp-buffer)) (width 0)) - (save-excursion - (set-buffer tmp-buffer) + (with-current-buffer tmp-buffer (erase-buffer) (apply 'call-process (expand-file-name mh-scan-prog mh-progs) nil '(t nil) nil
--- a/lisp/mh-e/mh-search.el Thu Nov 05 21:01:32 2009 +0000 +++ b/lisp/mh-e/mh-search.el Thu Nov 05 21:04:59 2009 +0000 @@ -1463,8 +1463,7 @@ ;; If source folder not open, just delete the messages... (apply #'mh-exec-cmd "rmm" folder (mh-coalesce-msg-list msgs)) ;; Otherwise delete the messages in the source buffer... - (save-excursion - (set-buffer folder) + (with-current-buffer folder (let ((old-refile-list mh-refile-list) (old-delete-list mh-delete-list)) (setq mh-refile-list nil @@ -1642,8 +1641,7 @@ (mh-coalesce-msg-list msgs))) ;; Update source folder buffer if we have it open... (when (get-buffer folder) - (save-excursion - (set-buffer folder) + (with-current-buffer folder (mh-put-msg-in-seq msgs seq)))) (mh-index-matching-source-msgs msgs)) folders)))) @@ -1667,8 +1665,7 @@ (mh-coalesce-msg-list msgs))) ;; Update source folder buffer if we have it open... (when (get-buffer folder) - (save-excursion - (set-buffer folder) + (with-current-buffer folder (mh-delete-msg-from-seq msgs seq t)))) (mh-index-matching-source-msgs msgs)) folders)))) @@ -1853,9 +1850,8 @@ was copied. If present the checksum -> (origin-folder, origin-index) map is updated too." (clrhash mh-index-msg-checksum-map) - (save-excursion - ;; Clear temp buffer - (set-buffer (get-buffer-create mh-temp-checksum-buffer)) + ;; Clear temp buffer + (with-current-buffer (get-buffer-create mh-temp-checksum-buffer) (erase-buffer) ;; Run scan to check if any messages needs MD5 annotations at all (with-temp-buffer @@ -1895,8 +1891,7 @@ (mh-exec-cmd "anno" folder msg "-component" "X-MHE-Checksum" "-nodate" "-text" checksum "-inplace") ;; update maps - (save-excursion - (set-buffer folder) + (with-current-buffer folder (mh-index-update-single-msg msg checksum origin-map))) (forward-line))))) (mh-index-write-data))
--- a/lisp/mh-e/mh-seq.el Thu Nov 05 21:01:32 2009 +0000 +++ b/lisp/mh-e/mh-seq.el Thu Nov 05 21:04:59 2009 +0000 @@ -146,8 +146,7 @@ (seq-list mh-seq-list) (max-len 0)) (with-output-to-temp-buffer temp-buffer - (save-excursion - (set-buffer temp-buffer) + (with-current-buffer temp-buffer (erase-buffer) (message "Listing sequences ...") (insert "Sequences in folder " folder ":\n")
--- a/lisp/mh-e/mh-show.el Thu Nov 05 21:01:32 2009 +0000 +++ b/lisp/mh-e/mh-show.el Thu Nov 05 21:04:59 2009 +0000 @@ -326,8 +326,7 @@ (defun mh-invalidate-show-buffer () "Invalidate the show buffer so we must update it to use it." (if (get-buffer mh-show-buffer) - (save-excursion - (set-buffer mh-show-buffer) + (with-current-buffer mh-show-buffer (mh-unvisit-file)))) (defun mh-unvisit-file () @@ -511,8 +510,7 @@ "--" ["Narrow to Subject Sequence" mh-show-narrow-to-subject t] ["Narrow to Tick Sequence" mh-show-narrow-to-tick - (save-excursion - (set-buffer mh-show-folder-buffer) + (with-current-buffer mh-show-folder-buffer (and mh-tick-seq (mh-seq-msgs (mh-find-seq mh-tick-seq))))] ["Delete Rest of Same Subject" mh-show-delete-subject t] ["Toggle Tick Mark" mh-show-toggle-tick t]
--- a/lisp/mh-e/mh-speed.el Thu Nov 05 21:01:32 2009 +0000 +++ b/lisp/mh-e/mh-speed.el Thu Nov 05 21:04:59 2009 +0000 @@ -66,8 +66,7 @@ (defvar mh-folder-speedbar-menu-items '("--" ["Visit Folder" mh-speed-view - (save-excursion - (set-buffer speedbar-buffer) + (with-current-buffer speedbar-buffer (get-text-property (mh-line-beginning-position) 'mh-folder))] ["Expand Nested Folders" mh-speed-expand-folder (and (get-text-property (mh-line-beginning-position) 'mh-children-p) @@ -120,8 +119,8 @@ (defun mh-speed-stealth-update (&optional force) "Do stealth update. With non-nil FORCE, the update is always carried out." - (cond ((save-excursion (set-buffer speedbar-buffer) - (get-text-property (point-min) 'mh-level)) + (cond ((with-current-buffer speedbar-buffer + (get-text-property (point-min) 'mh-level)) ;; Execute this hook and *don't* run anything else (mh-speed-update-current-folder force) nil) @@ -326,8 +325,7 @@ "Given an MH-E BUFFER find the folder that should be highlighted. Do the right thing for the different kinds of buffers that MH-E uses." - (save-excursion - (set-buffer buffer) + (with-current-buffer buffer (cond ((eq major-mode 'mh-folder-mode) mh-current-folder) ((eq major-mode 'mh-show-mode) @@ -462,9 +460,8 @@ (or (not (equal (car old-pair) unseen)) (not (equal (cdr old-pair) total))))) (setf (gethash folder mh-speed-flists-cache) (cons unseen total)) - (save-excursion - (when (buffer-live-p (get-buffer speedbar-buffer)) - (set-buffer speedbar-buffer) + (when (buffer-live-p (get-buffer speedbar-buffer)) + (with-current-buffer speedbar-buffer (speedbar-with-writable (when (get-text-property (point-min) 'mh-level) (let ((pos (gethash folder mh-speed-folder-map)) @@ -501,8 +498,7 @@ (defun mh-speed-invalidate-map (folder) "Remove FOLDER from various optimization caches." (interactive (list "")) - (save-excursion - (set-buffer speedbar-buffer) + (with-current-buffer speedbar-buffer (let* ((speedbar-update-flag nil) (last-slash (mh-search-from-end ?/ folder)) (parent (if last-slash (substring folder 0 last-slash) nil)) @@ -555,8 +551,7 @@ (defun mh-speed-add-folder (folder) "Add FOLDER since it is being created. The function invalidates the latest ancestor that is present." - (save-excursion - (set-buffer speedbar-buffer) + (with-current-buffer speedbar-buffer (let ((speedbar-update-flag nil) (last-slash (mh-search-from-end ?/ folder)) (ancestor folder)
--- a/lisp/mh-e/mh-thread.el Thu Nov 05 21:01:32 2009 +0000 +++ b/lisp/mh-e/mh-thread.el Thu Nov 05 21:04:59 2009 +0000 @@ -647,8 +647,7 @@ (defun mh-thread-set-tables (folder) "Use the tables of FOLDER in current buffer." (flet ((mh-get-table (symbol) - (save-excursion - (set-buffer folder) + (with-current-buffer folder (symbol-value symbol)))) (setq mh-thread-id-hash (mh-get-table 'mh-thread-id-hash)) (setq mh-thread-subject-hash (mh-get-table 'mh-thread-subject-hash))