org-mac-iCal icon indicating copy to clipboard operation
org-mac-iCal copied to clipboard

Errors when the diary file does not exist

Open rpgoldman opened this issue 3 years ago • 1 comments

On my first try using this, I got an error because I did not have a diary file.

I fixed this by modifying the top of org-mac-iCal as follows:

(defun org-mac-iCal ()
  "Selects checked calendars in iCal.app and imports them into
the the Emacs diary"
  (interactive)

  ;; kill diary buffers then empty diary files to avoid duplicates
  (setq currentBuffer (buffer-name))
  (setq openBuffers (mapcar (function buffer-name) (buffer-list)))
  (omi-kill-diary-buffer openBuffers)
  (with-temp-buffer
    (when (file-exists-p diary-file) ; <------ added this check
     (insert-file-contents diary-file))
    (delete-region (point-min) (point-max))
    (write-region (point-min) (point-max) diary-file))

Hope that's helpful. Seemed too trivial to bother with a full clone and pull request...

rpgoldman avatar Sep 11 '22 18:09 rpgoldman

Actually, reading further after fixing this, there seem to be a lot of issues with this, and also some pretty scary practices, like using the ~/Library/Calendars directory in a way that is really only appropriate to a temp directory, and renaming .ics files, instead of copying them. So I am going to fork this.

rpgoldman avatar Sep 11 '22 18:09 rpgoldman