Re: word count note

"thomas knoll" <[email protected]> Sun, 7 May 2006 15:56:25 -0500
Newsgroups gmane.emacs.wiki.general
Message-ID <[email protected]>
I didn't quite work.
Here is what is in *Messages*:
302 occurrences
if: Format specifier doesn't match argument type

302 is the correct number, but it only prints "Format specifier
doesn't match argument type" to the buffer.

On 5/7/06, Seth Falcon <[email protected]> wrote:
> "thomas knoll" <[email protected]> writes:
>
> > Can someone help me figure out how to tweak the function below that
> > will count the words in the current note? (i.e. between .# 's)
> >
> >   (defun count-words (start end)
> >     "Print number of words in the region."
> >     (interactive "r")
> >     (save-excursion
> >       (save-restriction
> >         (narrow-to-region start end)
> >         (goto-char (point-min))
> >         (count-matches "\\sw+"))))
> >   (defalias 'word-count 'count-words)
>
> Here's a blind stab...
>
> (defun syf/planner-get-note-range ()
>   "Return (start end) positions for current planner note or nil
> if not in a note."
>   (let* ((planner-note-regex "\\.\\(#[0-9]+\\)\\s-+\\(.*\\)")
>          (start nil)
>          (end nil))
>     (re-search-backward planner-note-regex nil t)
>     (setq start (match-end 2))
>     (if start
>         (progn
>           (forward-line)
>           (setq end (re-search-forward planner-note-regex nil t))
>           (if (not end)
>               (setq end (point-max))
>             (goto-char (match-beginning 1))
>             (forward-line -1)
>             (setq end (point)))
>           (list start end)))))
>
> (defun syf/planner-count-words-in-note ()
>   "Count the words in the current planner note."
>   (interactive)
>   (let ((range (syf/planner-get-note-range))
>         (count nil))
>     (if (not range)
>         (message "No planner note found.")
>       (setq count (count-words (car range) (cadr range)))
>       (message "This note has %d words" count))))
>
>
>
> _______________________________________________
> emacs-wiki-discuss mailing list
> [email protected]
> http://lists.nongnu.org/mailman/listinfo/emacs-wiki-discuss
>


--
##[.:dydimustk:.]###############
web:     http://dydimustk.com/
vox:       651.210.2321
skype:   dydimustk
aim:       dyd1mustk

semper reformanda:
http://www.EmergingLeadersNetwork.org

_______________________________________________
emacs-wiki-discuss mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/emacs-wiki-discuss