Function: diary-icalendar-entry-bounds

diary-icalendar-entry-bounds is a byte-compiled function defined in diary-icalendar.el.gz.

Signature

(diary-icalendar-entry-bounds)

Documentation

Return markers (START END) bounding the diary entry around point.

If point is not in an entry, return nil.

Source Code

;; Defined in /usr/src/emacs/lisp/calendar/diary-icalendar.el.gz
;; TODO: move to diary-lib.el?
(defun di:entry-bounds ()
  "Return markers (START END) bounding the diary entry around point.
If point is not in an entry, return nil."
  (save-excursion
    (let* ((pt (point))
           (bound (point-min))
           (start (make-marker))
           (end (make-marker)))
      (when (re-search-backward "^[[:space:]]*$" nil t)
        (setq bound (match-end 0)))
      (goto-char pt)
      (cond ((looking-at di:entry-regexp)
             (set-marker start (match-beginning 0))
             (set-marker end (match-end 0)))
            ((re-search-backward di:entry-regexp bound t)
             (set-marker start (match-beginning 0))
             ;; match again forward, to ensure we get the full entry;
             ;; see `re-search-backward':
             (goto-char start)
             (when (looking-at di:entry-regexp)
               (set-marker end (match-end 0))))
            (t nil))
      (when (and (marker-position start) (marker-position end))
        (list start end)))))