emacs-orgmode
[Top][All Lists]
Advanced

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

[Orgmode] org-capture: org-capture-place-item needs search bounds


From: sand
Subject: [Orgmode] org-capture: org-capture-place-item needs search bounds
Date: Tue, 12 Oct 2010 19:20:23 -0700

In org-capture-place-item, excerpted here...

 (defun org-capture-place-item ()
   "Place the template as a new plain list item."
   (let* ((txt (org-capture-get :template))
          (target-entry-p (org-capture-get :target-entry-p))
          (ind 0)
          beg end)
     (cond
      ((org-capture-get :exact-position)
       (goto-char (org-capture-get :exact-position)))
      ((not target-entry-p)
       ;; Insert as top-level entry, either at beginning or at end of file
       (setq beg (point-min) end (point-max)))
      (t
       (setq beg (1+ (point-at-eol))
             end (save-excursion (outline-next-heading) (point)))))
     (if (org-capture-get :prepend)
         (progn
           (goto-char beg)
           (if (re-search-forward (concat "^" (org-item-re)) nil t)
               (progn
                 (goto-char (match-beginning 0))
                 (setq ind (org-get-indentation)))
             (goto-char end)
             (setq ind 0)))
       (goto-char end)
       (if (re-search-backward (concat "^" (org-item-re)) nil t)
           (progn
             (setq ind (org-get-indentation))
             (org-end-of-item))
         (setq ind 0)))
 [...]

the function needs to bound re-search-forward by END, and it needs to bound  
re-search-backward by BEG.  As it stands right now, if the target location 
doesn't contain an item already, the function will happily pick the nearest 
list in a preceeding or following entry.

Derek

-- 
Derek Upham
address@hidden



reply via email to

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