emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Keith David Bershatsky <esq@lawlist.com>
To: Nicolas Richard <theonewiththeevillook@yahoo.fr>
Cc: 16265@debbugs.gnu.org
Subject: bug#16265: 24.3.50; re-search-forward (error "Invalid search bound (wrong side of point)")
Date: Sat, 28 Dec 2013 12:44:20 -0800	[thread overview]
Message-ID: <m2ob40iu3f.wl%esq@lawlist.com> (raw)
In-Reply-To: <m2fvpezvid.wl%esq@lawlist.com>

Nicolas:

This example demonstrates the problem caused when `org-capture` damages the line numbers in the `org-agenda-files`, making it impossible to go to the bottom of the buffer with (goto-char (point-max))  --  consequently, re-search-backward fails -- other functions fail also, e.g., `org-sort-entries`.

(defun example ()
(interactive)
   (let* (
      (org-todo-keywords '((sequence "Active(a)" "Next Action(n)" "Reference(r)"  "Someday(s)" "Delegated(d)" "|" "None(N)") ))
      (sample-todo (concat
        "* TASKS\n\n"
        "** Active [#A] smith @ drawer-one (fishing) | drawer-two (tennis). :lawlist:\n"
        "   DEADLINE: <2013-12-21 Sat 17:00>  SCHEDULED: <2013-12-21 Sat>\n"
        "   :PROPERTIES:\n"
        "   :DRAWER-ONE:  fishing\n"
        "   :DRAWER-TWO:  tennis\n"
        "   :END:\n\n"
        "** Next-Action [#B] doe @ drawer-one (football) | drawer-two (bowling). :fred:\n"
        "   DEADLINE: <2013-12-22 Sun 08:30>  SCHEDULED: <2013-12-22 Sun>\n"
        "   :PROPERTIES:\n"
        "   :DRAWER-ONE:  football\n"
        "   :DRAWER-TWO:  bowling\n"
        "   :END:\n\n"
        "* EVENTS\n\n"
        "** Reference [#C] john @ drawer-one (fishing) | drawer-two (sky-diving). :george:\n"
        "   DEADLINE: <2013-12-23 Mon 10:15>  SCHEDULED: <2013-12-23 Mon>\n"
        "   :PROPERTIES:\n"
        "   :DRAWER-ONE:  fishing\n"
        "   :DRAWER-TWO:  sky-diving\n"
        "   :END:\n\n"
        "* UNDATED\n\n"
        "** Someday [#D] jane @ drawer-one (basket-ball) | drawer-two (bowling). :sam:\n"
        "   DEADLINE: <2013-12-24 Tues 12:00>  SCHEDULED: <2013-12-24 Tues>\n"
        "   :PROPERTIES:\n"
        "   :DRAWER-ONE:  basket-ball\n"
        "   :DRAWER-TWO:  bowling\n"
        "   :END:")))
      (if (get-buffer "foo.org")
        (progn
          (switch-to-buffer "foo.org")
          (erase-buffer)
          (delete-other-windows))
        (switch-to-buffer (get-buffer-create "foo.org")))
      (org-mode)
      (linum-mode 1)
      (insert sample-todo)
      (goto-char (point-min))
      (or (y-or-n-p (format "For this example work, you must save this buffer as a file.  Proceed with example?"))
          (error "Canceled."))
      (write-file "~/Desktop/foo.org" t)
      (let* (
          (filename (buffer-file-name))
          (org-agenda-files (list filename))
          (org-capture-templates '(("n" "Next Action" entry (file+headline filename "TASKS")
      "** Next Action [#A] %?\n   DEADLINE: <%<%Y-%m-%d %a>>\n   :PROPERTIES:\n   :ToodledoID:\n   :ToodledoFolder: TASKS\n   :Hash:\n   :END:"
      :empty-lines 1))))
(search-backward-example)
(org-capture nil "n")
(message "-----------------------------")
(message "Here we can see that the line numbers in 'foo.org' got messed up.")
(sit-for 5)
(insert "Hello World! :lawlist:")
(org-capture-finalize)
(search-backward-example)
(message "-----------------------------")
(message "Here is where things really went wrong.  It's searching the WRONG todo.")
(message "-----------------------------")
(switch-to-buffer "*Messages*"))))


(defun search-backward-example ()
(require 'org-element)
  (let* (element todo-state title deadline scheduled day month year
        (org-todo-keywords '((sequence "Active(a)" "Next Action(n)" "Reference(r)"  "Someday(s)" "Delegated(d)" "|" "None(N)") )))
    (goto-char (point-max))
    (while (re-search-backward "^\*\* \\(Reference\\)" nil t)
      (setq element (org-element-at-point))
      (setq todo-state (org-element-property :todo-keyword element))
      (setq title (org-element-property :title element))
      (setq deadline (ignore-errors (org-element-property :deadline element) ))
      (setq scheduled (ignore-errors (org-element-property :scheduled element) ))
      (setq day (ignore-errors (org-element-property :day-start scheduled)))
      (setq month (ignore-errors (org-element-property :month-start scheduled)))
      (setq year (ignore-errors (org-element-property :year-start scheduled)))
      (message "-----------------------------")
      (message "todo-state:  %s" todo-state)
      (message "deadline:  %s" deadline)
      (message "scheduled:  %s" scheduled)
      (message "title:  %s" title)
      (message "day:  %s" day)
      (message "month:  %s" month)
      (message "year:  %s" year)
      (message "-----------------------------") )))

       reply	other threads:[~2013-12-28 20:45 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <m2fvpezvid.wl%esq@lawlist.com>
2013-12-28 20:44 ` Keith David Bershatsky [this message]
2013-12-31 12:07   ` bug#16265: 24.3.50; re-search-forward (error "Invalid search bound (wrong side of point)") Nicolas Richard
2013-12-31 14:16     ` Nicolas Richard
2013-12-31 17:37 ` Keith David Bershatsky
2014-01-01  9:46   ` Nicolas Richard
2014-01-01 17:50   ` Eli Zaretskii
2014-01-02  1:30 ` Keith David Bershatsky
     [not found] <m2mwjf8923.wl%esq@lawlist.com>
2014-01-02  3:38 ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m2ob40iu3f.wl%esq@lawlist.com \
    --to=esq@lawlist.com \
    --cc=16265@debbugs.gnu.org \
    --cc=theonewiththeevillook@yahoo.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).