comparison lisp/mh-e/mh-e.el @ 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 b7557958fa7d
children 1d1d5d9bd884
comparison
equal deleted inserted replaced
105866:3367f0022cf2 105867:00c0adbb54a9
504 (defun mh-exec-cmd (command &rest args) 504 (defun mh-exec-cmd (command &rest args)
505 "Execute mh-command COMMAND with ARGS. 505 "Execute mh-command COMMAND with ARGS.
506 The side effects are what is desired. Any output is assumed to be 506 The side effects are what is desired. Any output is assumed to be
507 an error and is shown to the user. The output is not read or 507 an error and is shown to the user. The output is not read or
508 parsed by MH-E." 508 parsed by MH-E."
509 (save-excursion 509 (with-current-buffer (get-buffer-create mh-log-buffer)
510 (set-buffer (get-buffer-create mh-log-buffer))
511 (let* ((initial-size (mh-truncate-log-buffer)) 510 (let* ((initial-size (mh-truncate-log-buffer))
512 (start (point)) 511 (start (point))
513 (args (mh-list-to-string args))) 512 (args (mh-list-to-string args)))
514 (apply 'call-process (expand-file-name command mh-progs) nil t nil args) 513 (apply 'call-process (expand-file-name command mh-progs) nil t nil args)
515 (when (> (buffer-size) initial-size) 514 (when (> (buffer-size) initial-size)
524 523
525 (defun mh-exec-cmd-error (env command &rest args) 524 (defun mh-exec-cmd-error (env command &rest args)
526 "In environment ENV, execute mh-command COMMAND with ARGS. 525 "In environment ENV, execute mh-command COMMAND with ARGS.
527 ENV is nil or a string of space-separated \"var=value\" elements. 526 ENV is nil or a string of space-separated \"var=value\" elements.
528 Signals an error if process does not complete successfully." 527 Signals an error if process does not complete successfully."
529 (save-excursion 528 (with-current-buffer (get-buffer-create mh-temp-buffer)
530 (set-buffer (get-buffer-create mh-temp-buffer))
531 (erase-buffer) 529 (erase-buffer)
532 (let ((process-environment process-environment)) 530 (let ((process-environment process-environment))
533 ;; XXX: We should purge the list that split-string returns of empty 531 ;; XXX: We should purge the list that split-string returns of empty
534 ;; strings. This can happen in XEmacs if leading or trailing spaces 532 ;; strings. This can happen in XEmacs if leading or trailing spaces
535 ;; are present. 533 ;; are present.
545 If FILTER is non-nil then it is used to process the output 543 If FILTER is non-nil then it is used to process the output
546 otherwise the default filter `mh-process-daemon' is used. See 544 otherwise the default filter `mh-process-daemon' is used. See
547 `set-process-filter' for more details of FILTER. 545 `set-process-filter' for more details of FILTER.
548 546
549 ARGS are passed to COMMAND as command line arguments." 547 ARGS are passed to COMMAND as command line arguments."
550 (save-excursion 548 (with-current-buffer (get-buffer-create mh-log-buffer)
551 (set-buffer (get-buffer-create mh-log-buffer))
552 (mh-truncate-log-buffer)) 549 (mh-truncate-log-buffer))
553 (let* ((process-connection-type nil) 550 (let* ((process-connection-type nil)
554 (process (apply 'start-process 551 (process (apply 'start-process
555 command nil 552 command nil
556 (expand-file-name command mh-progs) 553 (expand-file-name command mh-progs)
648 status 645 status
649 (goto-char (point-min)) 646 (goto-char (point-min))
650 (insert (if (integerp status) 647 (insert (if (integerp status)
651 (format "%s: exit code %d\n" command status) 648 (format "%s: exit code %d\n" command status)
652 (format "%s: %s\n" command status))) 649 (format "%s: %s\n" command status)))
653 (save-excursion 650 (let ((error-message (buffer-substring (point-min) (point-max))))
654 (let ((error-message (buffer-substring (point-min) (point-max)))) 651 (with-current-buffer (get-buffer-create mh-log-buffer)
655 (set-buffer (get-buffer-create mh-log-buffer))
656 (mh-truncate-log-buffer) 652 (mh-truncate-log-buffer)
657 (insert error-message))) 653 (insert error-message)))
658 (error "%s failed, check buffer %s for error message" 654 (error "%s failed, check buffer %s for error message"
659 command mh-log-buffer))) 655 command mh-log-buffer)))
660 656
741 (add-to-list 'mh-variants variant))))) 737 (add-to-list 'mh-variants variant)))))
742 mh-variants))) 738 mh-variants)))
743 739
744 (defun mh-variant-info (dir) 740 (defun mh-variant-info (dir)
745 "Return MH variant found in DIR, or nil if none present." 741 "Return MH variant found in DIR, or nil if none present."
746 (save-excursion 742 (let ((tmp-buffer (get-buffer-create mh-temp-buffer)))
747 (let ((tmp-buffer (get-buffer-create mh-temp-buffer))) 743 (with-current-buffer tmp-buffer
748 (set-buffer tmp-buffer)
749 (cond 744 (cond
750 ((mh-variant-mh-info dir)) 745 ((mh-variant-mh-info dir))
751 ((mh-variant-nmh-info dir)) 746 ((mh-variant-nmh-info dir))
752 ((mh-variant-gnu-mh-info dir)))))) 747 ((mh-variant-gnu-mh-info dir))))))
753 748