Commit b5553d47 authored by Stefan Monnier's avatar Stefan Monnier
Browse files

* 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.
parent 2adaf057
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.
......
......@@ -135,8 +135,7 @@ COMMA-SEPARATOR is non-nil."
"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 @@ string is converted to lower case."
(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 @@ alias. In the latter case, the alias serves as an additional
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)
......
......@@ -473,8 +473,7 @@ See also `mh-compose-forward-as-mime-flag',
(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:"))
......
......@@ -506,8 +506,7 @@ Adds double-quotes around entire string and quotes the characters
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 @@ parsed by MH-E."
"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 @@ otherwise the default filter `mh-process-daemon' is used. See
`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 @@ Set mark after inserted text."
(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 @@ is described by the variable `mh-variants'."
(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))
......
......@@ -840,8 +840,8 @@ From a program, edit MESSAGE; nil means edit current message."
;; 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 @@ structures."
(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 @@ the command \\[mh-refile-or-write-again]."
(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 @@ The default folder name is generated by the option
"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
......
......@@ -145,8 +145,7 @@ Display the results only if something went wrong."
(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 @@ to the command."
(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 @@ storing the content of these messages."
(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 @@ See `mh-store-msg' for a description of DIRECTORY."
(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 @@ See `mh-store-msg' for a description of DIRECTORY."
(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)))))
......
......@@ -706,9 +706,9 @@ the supercite flavors, the hook `mail-citation-hook' is ignored
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)))
......
......@@ -410,8 +410,7 @@ do the work."
(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 @@ HANDLE is associated with the undisplayer FUNCTION."
(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 @@ Returns nil if file command not on system."
(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"
......
......@@ -105,8 +105,7 @@ If FILE is nil, then the messages are spooled to the printer."
(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
......
......@@ -451,8 +451,7 @@ with `mh-scan-msg-format-string'."
(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
......
......@@ -1463,8 +1463,7 @@ user has marked in the index buffer."
;; 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 @@ attempt to update the source folder buffer if we have it open."
(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 @@ attempt to update the source folder buffer if present."
(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 @@ index folder to the original folder and message from whence it
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 @@ origin-index) map is updated too."
(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))
......
......@@ -146,8 +146,7 @@ The list appears in a buffer named \"*MH-E Sequences*\"."
(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")
......
......@@ -326,8 +326,7 @@ ignored if VISIBLE-HEADERS is non-nil."
(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 @@ still visible.\n")
"--"
["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]
......
......@@ -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 @@ update."
(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 @@ The function will expand out parent folders of FOLDER if needed."
"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 @@ be handled next."
(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 @@ be handled next."
(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 @@ be handled next."
(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)
......
......@@ -647,8 +647,7 @@ Only information about messages in MSG-LIST are added to the tree."
(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))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment