emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: New version of todo-mode.el (announcement + user guide)


From: Stefan Monnier
Subject: Re: New version of todo-mode.el (announcement + user guide)
Date: Sat, 15 Jun 2013 20:44:03 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)

> restore the proper display.  But what happens between widening and
> re-narrowing is different in the two situations (indicated below by the

You could unify the two with something like

(defvar diary-goto-entry-function
    (lambda (pos)
      (if (number-or-marker-p pos) (goto-char pos))
        (goto-char (point-min))
        (when (re-search-forward (format "%s.*\\(%s\\)"
                                         (regexp-quote (car locator))
                                         (regexp-quote (nth 1 locator)))
                                 nil t)
          (goto-char (match-beginning 1))))
  "Function called to jump to a diary entry.
Called with one argument which can be either a simple buffer position,
or a description of the form (FOO BAR) where FOO is some leading text
and BAR is the actual text of the entry.")

(defun diary-goto-entry (button)
  "Jump to the diary entry for the BUTTON at point."
  (let* ((locator (button-get button 'locator))
         (marker (car locator))
         (file (nth 1 locator))
         (place (cond
                 ;; If marker pointing to diary location is valid, use that.
                 ((and marker (marker-buffer marker))
                  (cons (marker-buffer marker) marker))
                 ;; Marker is invalid (eg buffer has been killed).
                 ((and file (file-exists-p file))
                  (cons (find-file-noselect file) (cddr locator)))
                 (t (message "Unable to locate this diary entry") nil))))
    (when place
      (pop-to-buffer (car place))
      (funcall diary-goto-entry-function (cdr place)))))

> Actually, I don't see why the first situation, using a valid marker, is
> needed.

I don't have any opinion on that part because I don't use this part of
the diary.


        Stefan



reply via email to

[Prev in Thread] Current Thread [Next in Thread]