bugPlanner.el and related modules - Bugs: bug #14968, planner-create-note: bad regexp...

Show feedback again

bug #14968: planner-create-note: bad regexp that matches lines containing any char followed by a "#"

Submitted by:  Brent Goodrick <bgoodr>
Submitted on:  Fri 18 Dec 2009 03:37:21 PM UTC  
Category: SourceSeverity: 4 - Important
Priority: 5 - NormalStatus: None
Privacy: PublicAssigned to: None
Open/Closed: Open

Add a New Comment (Rich MarkupRich Markup):

You are not logged in

Please log in, so followups can be emailed to you.


Fri 18 Dec 2009 03:37:21 PM UTC, original submission:

planner-create-note uses a regular expression that missing a
backslash. I have fixed this locally in my copy of Planner v3.42 with
the following code (see the "BUGGY REGEXP" comment below).

The failure can show up when the current regexp matches a line
that has any character followed by a "#" character. The extra
backslash is needed specifically to match the first note in the
Planner/Muse buffer.

You can see the difference between the two regular expressions by
using the rx package. Go into a scratch (lisp-interaction) buffer
and type the following forms, followed each time by the C-j key

(rx bol nonl "#")

(rx bol ".#")

So, probably a better way to express that regexp is to just use
an rx form, which seems to go easier on the eyeball:

(rx bol
(group (+ digit))

Here is my patched version:

(defun planner-create-note (&optional page)
"Create a note to be remembered in PAGE (today if PAGE is nil).
If `planner-reverse-chronological-notes' is non-nil, create the
note at the beginning of the notes section; otherwise, add it to
the end. Position point after the anchor."
(interactive (list (and (planner-derived-mode-p 'planner-mode)
(planner-goto (or page
(and (planner-derived-mode-p 'planner-mode)
(planner-seek-to-first 'notes)
(when (planner-narrow-to-section 'notes)
(let ((total 0))
(goto-char (point-min))
(while (re-search-forward
;; BUGGY REGEXP --> "^\.#\\([0-9]+\\)\\s-+"
(rx bol
(group (+ digit))
nil t)
(setq total (max total (string-to-number (match-string 1)))))
(if planner-reverse-chronological-notes
(progn (goto-char (point-min))
(forward-line 1)
(skip-chars-forward "\n"))
(goto-char (point-max))
(skip-chars-backward "\n")
(when (= (forward-line 1) 1) (insert "\n"))
(when (= (forward-line 1) 1) (insert "\n")))
(insert ".#" (number-to-string (1+ total)) " ")
(unless (eobp) (save-excursion (insert "\n\n")))
(1+ total)))))


Brent Goodrick <bgoodr>


(Note: upload size limit is set to 1024 kB, after insertion of the required escape characters.)

Attach File(s):

No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -unavailable- added by bgoodr (Submitted the item)

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.


    Error: not logged in



    No Changes Have Been Made to This Item
    Show feedback again

    Back to the top

    Powered by Savane 3.1-cleanup