emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* % (org-agenda-bulk-mark-regexp) in agenda view problems
@ 2011-10-01  7:38 netty hacky
  2011-10-01 22:14 ` netty hacky
  0 siblings, 1 reply; 3+ messages in thread
From: netty hacky @ 2011-10-01  7:38 UTC (permalink / raw)
  To: Bastien Guerry; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 1055 bytes --]

Hi Bastien,

I'm having two problems with the % command (org-agenda-bulk-mark-regexp) in
Org-mode agenda view.

1.  If I use "." as the search string, I get "Wrong type argument:
number-or-marker-p, nil".  And my workaround is to change the line "(let
(entries-marked)" in org-agenda.el to "(let ((entries-marked 0))".

2. If I use ".*" as the search string, I get "Wrong type argument: stringp,
nil".  After some edebugging, I found the reason is that in
org-agenda-bulk-mark-regexp, re-search-forward moved the point to the end of
the line (since ".*" matches the whole line), causing (get-text-property
(point) 'txt) to return nil, in turn caused string-match to throw the
error.  I think this may happen to other regexps, as long as the strings
matched include the last character in the line.  I'm new to Emacs Lisp so
I'm not sure how to fix this one.

Wondering why it seems only me having these two problems.

I am using MacPorts' Emacs and Org-mode:
Emacs  : GNU Emacs 23.3.1 (x86_64-apple-darwin10.8.0)
Package: Org-mode version 7.7

Thanks,
Net

[-- Attachment #2: Type: text/html, Size: 1205 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: % (org-agenda-bulk-mark-regexp) in agenda view problems
  2011-10-01  7:38 % (org-agenda-bulk-mark-regexp) in agenda view problems netty hacky
@ 2011-10-01 22:14 ` netty hacky
  2011-10-02  9:26   ` netty hacky
  0 siblings, 1 reply; 3+ messages in thread
From: netty hacky @ 2011-10-01 22:14 UTC (permalink / raw)
  To: Bastien Guerry; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 2582 bytes --]

Hi Bastien,

I found a third problem of org-agenda-bulk-mark-regexp, it does not work
well on daily/weekly agenda view.  Basically it chokes on lines that is not
a regular headline, like date labels, dairy entries and grid lines.

So to show I am not merely a leech on this list, I come up with my version
here, most of the ugly code are to deal with the way org-agenda-bulk-mark
works now (e.g., returning nil when successful):

(defun org-agenda-bulk-mark-regexp
(regexp)

  "Mark entries match
REGEXP."

  (interactive "sMark entries matching regexp:
")


(save-excursion

      (goto-char
(point-min))

      (let ((entries-marked
0))

        (while (not
(eobp))

          (unless
(and

                   (not (get-char-property (point)
'invisible))

                   (not (org-get-at-bol
'org-agenda-diary-link))

                   (org-get-at-bol
'org-hd-marker)

                   (let
(txt-property)

                     (setq txt-property (get-char-property (point)
'txt))

                     (string-match regexp
txt-property))

                   (not (call-interactively
'org-agenda-bulk-mark))

                   (setq entries-marked (+ entries-marked
1)))

            (beginning-of-line
2)))

        (if (zerop
entries-marked)

            (message "No entry matching this
regexp.")

          (message "%d entries marked for bulk action" entries-marked)))))

Thanks,
Net

On Sat, Oct 1, 2011 at 12:38 AM, netty hacky <netty.hacky@gmail.com> wrote:

> Hi Bastien,
>
> I'm having two problems with the % command (org-agenda-bulk-mark-regexp) in
> Org-mode agenda view.
>
> 1.  If I use "." as the search string, I get "Wrong type argument:
> number-or-marker-p, nil".  And my workaround is to change the line "(let
> (entries-marked)" in org-agenda.el to "(let ((entries-marked 0))".
>
> 2. If I use ".*" as the search string, I get "Wrong type argument: stringp,
> nil".  After some edebugging, I found the reason is that in
> org-agenda-bulk-mark-regexp, re-search-forward moved the point to the end of
> the line (since ".*" matches the whole line), causing (get-text-property
> (point) 'txt) to return nil, in turn caused string-match to throw the
> error.  I think this may happen to other regexps, as long as the strings
> matched include the last character in the line.  I'm new to Emacs Lisp so
> I'm not sure how to fix this one.
>
> Wondering why it seems only me having these two problems.
>
> I am using MacPorts' Emacs and Org-mode:
> Emacs  : GNU Emacs 23.3.1 (x86_64-apple-darwin10.8.0)
> Package: Org-mode version 7.7
>
> Thanks,
> Net
>
>

[-- Attachment #2: Type: text/html, Size: 5192 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: % (org-agenda-bulk-mark-regexp) in agenda view problems
  2011-10-01 22:14 ` netty hacky
@ 2011-10-02  9:26   ` netty hacky
  0 siblings, 0 replies; 3+ messages in thread
From: netty hacky @ 2011-10-02  9:26 UTC (permalink / raw)
  To: Bastien Guerry; +Cc: emacs-orgmode

Sorry, didn't realized I wasn't sending email in plain text.

On Sat, Oct 1, 2011 at 3:14 PM, netty hacky <netty.hacky@gmail.com> wrote:
>
> Hi Bastien,
>
> I found a third problem of org-agenda-bulk-mark-regexp, it does not work well on daily/weekly agenda view.  Basically it chokes on lines that is not a regular headline, like date labels, dairy entries and grid lines.
>
> So to show I am not merely a leech on this list, I come up with my version here, most of the ugly code are to deal with the way org-agenda-bulk-mark works now (e.g., returning nil when successful):
>
> (defun org-agenda-bulk-mark-regexp (regexp)
>   "Mark entries match REGEXP."
>   (interactive "sMark entries matching regexp: ")
>     (save-excursion
>       (goto-char (point-min))
>       (let ((entries-marked 0))
>         (while (not (eobp))
>           (unless (and
>                    (not (get-char-property (point) 'invisible))
>                    (not (org-get-at-bol 'org-agenda-diary-link))
>                    (org-get-at-bol 'org-hd-marker)
>                    (let (txt-property)
>                      (setq txt-property (get-char-property (point) 'txt))
>                      (string-match regexp txt-property))
>                    (not (call-interactively 'org-agenda-bulk-mark))
>                    (setq entries-marked (+ entries-marked 1)))
>             (beginning-of-line 2)))
>         (if (zerop entries-marked)
>             (message "No entry matching this regexp.")
>           (message "%d entries marked for bulk action" entries-marked)))))
>
> Thanks,
> Net
>
> On Sat, Oct 1, 2011 at 12:38 AM, netty hacky <netty.hacky@gmail.com> wrote:
>>
>> Hi Bastien,
>>
>> I'm having two problems with the % command (org-agenda-bulk-mark-regexp) in Org-mode agenda view.
>>
>> 1.  If I use "." as the search string, I get "Wrong type argument: number-or-marker-p, nil".  And my workaround is to change the line "(let (entries-marked)" in org-agenda.el to "(let ((entries-marked 0))".
>>
>> 2. If I use ".*" as the search string, I get "Wrong type argument: stringp, nil".  After some edebugging, I found the reason is that in org-agenda-bulk-mark-regexp, re-search-forward moved the point to the end of the line (since ".*" matches the whole line), causing (get-text-property (point) 'txt) to return nil, in turn caused string-match to throw the error.  I think this may happen to other regexps, as long as the strings matched include the last character in the line.  I'm new to Emacs Lisp so I'm not sure how to fix this one.
>>
>> Wondering why it seems only me having these two problems.
>>
>> I am using MacPorts' Emacs and Org-mode:
>> Emacs  : GNU Emacs 23.3.1 (x86_64-apple-darwin10.8.0)
>> Package: Org-mode version 7.7
>>
>> Thanks,
>> Net
>>
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-10-02  9:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-01  7:38 % (org-agenda-bulk-mark-regexp) in agenda view problems netty hacky
2011-10-01 22:14 ` netty hacky
2011-10-02  9:26   ` netty hacky

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).