comparison lisp/calendar/diary-lib.el @ 90044:cb7f41387eb3

Revision: miles@gnu.org--gnu-2004/emacs--unicode--0--patch-70 Merge from emacs--cvs-trunk--0 Patches applied: * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-669 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-678 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-679 Merge from gnus--rel--5.10 * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-680 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-688 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-689 Merge from gnus--rel--5.10 * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-690 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-691 Update from CVS * miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-69 Merge from emacs--cvs-trunk--0 * miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-70 - miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-71 Update from CVS
author Miles Bader <miles@gnu.org>
date Fri, 12 Nov 2004 02:53:04 +0000
parents e23928ac5a97 e47a5c4e43ff
children eac554634bfa
comparison
equal deleted inserted replaced
90043:e24e2e78deda 90044:cb7f41387eb3
1972 subject)) 1972 subject))
1973 (save-buffer)))) 1973 (save-buffer))))
1974 (throw 'finished t)))) 1974 (throw 'finished t))))
1975 nil)) 1975 nil))
1976 1976
1977 (defun diary-from-outlook () 1977 (defun diary-from-outlook (&optional noconfirm)
1978 "Maybe snarf diary entry from current Outlook-generated message. 1978 "Maybe snarf diary entry from current Outlook-generated message.
1979 Currently knows about Gnus and Rmail modes." 1979 Currently knows about Gnus and Rmail modes. Unless the optional
1980 (interactive) 1980 argument NOCONFIRM is non-nil (which is the case when this
1981 function is called interactively), then if an entry is found the
1982 user is asked to confirm its addition."
1983 (interactive "p")
1981 (let ((func (cond 1984 (let ((func (cond
1982 ((eq major-mode 'rmail-mode) 1985 ((eq major-mode 'rmail-mode)
1983 #'diary-from-outlook-rmail) 1986 #'diary-from-outlook-rmail)
1984 ((memq major-mode '(gnus-summary-mode gnus-article-mode)) 1987 ((memq major-mode '(gnus-summary-mode gnus-article-mode))
1985 #'diary-from-outlook-gnus) 1988 #'diary-from-outlook-gnus)
1986 (t (error "Don't know how to snarf in `%s'" major-mode))))) 1989 (t (error "Don't know how to snarf in `%s'" major-mode)))))
1987 (if (interactive-p) 1990 (funcall func noconfirm)))
1988 (call-interactively func)
1989 (funcall func))))
1990 1991
1991 1992
1992 (defvar gnus-article-mime-handles) 1993 (defvar gnus-article-mime-handles)
1993 (defvar gnus-article-buffer) 1994 (defvar gnus-article-buffer)
1994 1995
1995 (autoload 'gnus-fetch-field "gnus-util") 1996 (autoload 'gnus-fetch-field "gnus-util")
1996 (autoload 'gnus-narrow-to-body "gnus") 1997 (autoload 'gnus-narrow-to-body "gnus")
1997 (autoload 'mm-get-part "mm-decode") 1998 (autoload 'mm-get-part "mm-decode")
1998 1999
1999 (defun diary-from-outlook-gnus () 2000 (defun diary-from-outlook-gnus (&optional noconfirm)
2000 "Maybe snarf diary entry from Outlook-generated message in Gnus. 2001 "Maybe snarf diary entry from Outlook-generated message in Gnus.
2001 Add this to `gnus-article-prepare-hook' to notice appointments 2002 Unless the optional argument NOCONFIRM is non-nil (which is the case when
2003 this function is called interactively), then if an entry is found the
2004 user is asked to confirm its addition.
2005 Add this function to `gnus-article-prepare-hook' to notice appointments
2002 automatically." 2006 automatically."
2003 (interactive) 2007 (interactive "p")
2004 (with-current-buffer gnus-article-buffer 2008 (with-current-buffer gnus-article-buffer
2005 (let ((subject (gnus-fetch-field "subject")) 2009 (let ((subject (gnus-fetch-field "subject"))
2006 (body (if gnus-article-mime-handles 2010 (body (if gnus-article-mime-handles
2007 ;; We're multipart. Don't get confused by part 2011 ;; We're multipart. Don't get confused by part
2008 ;; buttons &c. Assume info is in first part. 2012 ;; buttons &c. Assume info is in first part.
2009 (mm-get-part (nth 1 gnus-article-mime-handles)) 2013 (mm-get-part (nth 1 gnus-article-mime-handles))
2010 (save-restriction 2014 (save-restriction
2011 (gnus-narrow-to-body) 2015 (gnus-narrow-to-body)
2012 (buffer-string))))) 2016 (buffer-string)))))
2013 (when (diary-from-outlook-internal t) 2017 (when (diary-from-outlook-internal t)
2014 (when (or (interactive-p) 2018 (when (or noconfirm (y-or-n-p "Snarf diary entry? "))
2015 (y-or-n-p "Snarf diary entry? "))
2016 (diary-from-outlook-internal) 2019 (diary-from-outlook-internal)
2017 (message "Diary entry added")))))) 2020 (message "Diary entry added"))))))
2018 2021
2019 (custom-add-option 'gnus-article-prepare-hook 'diary-from-outlook-gnus) 2022 (custom-add-option 'gnus-article-prepare-hook 'diary-from-outlook-gnus)
2020 2023
2021 2024
2022 (defvar rmail-buffer) 2025 (defvar rmail-buffer)
2023 2026
2024 (defun diary-from-outlook-rmail () 2027 (defun diary-from-outlook-rmail (&optional noconfirm)
2025 "Maybe snarf diary entry from Outlook-generated message in Rmail." 2028 "Maybe snarf diary entry from Outlook-generated message in Rmail.
2026 (interactive) 2029 Unless the optional argument NOCONFIRM is non-nil (which is the case when
2030 this function is called interactively), then if an entry is found the
2031 user is asked to confirm its addition."
2032 (interactive "p")
2027 (with-current-buffer rmail-buffer 2033 (with-current-buffer rmail-buffer
2028 (let ((subject (mail-fetch-field "subject")) 2034 (let ((subject (mail-fetch-field "subject"))
2029 (body (buffer-substring (save-excursion 2035 (body (buffer-substring (save-excursion
2030 (rfc822-goto-eoh) 2036 (rfc822-goto-eoh)
2031 (point)) 2037 (point))
2032 (point-max)))) 2038 (point-max))))
2033 (when (diary-from-outlook-internal t) 2039 (when (diary-from-outlook-internal t)
2034 (when (or (interactive-p) 2040 (when (or noconfirm (y-or-n-p "Snarf diary entry? "))
2035 (y-or-n-p "Snarf diary entry? "))
2036 (diary-from-outlook-internal) 2041 (diary-from-outlook-internal)
2037 (message "Diary entry added")))))) 2042 (message "Diary entry added"))))))
2038 2043
2039 2044
2040 (provide 'diary-lib) 2045 (provide 'diary-lib)