From mboxrd@z Thu Jan 1 00:00:00 1970 From: netty hacky Subject: Re: % (org-agenda-bulk-mark-regexp) in agenda view problems Date: Sun, 2 Oct 2011 02:26:14 -0700 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([140.186.70.92]:33137) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RAIJN-0000pN-0m for emacs-orgmode@gnu.org; Sun, 02 Oct 2011 05:26:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RAIJL-0001IH-KK for emacs-orgmode@gnu.org; Sun, 02 Oct 2011 05:26:16 -0400 Received: from mail-vw0-f41.google.com ([209.85.212.41]:56176) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RAIJL-0001ID-Gs for emacs-orgmode@gnu.org; Sun, 02 Oct 2011 05:26:15 -0400 Received: by vws16 with SMTP id 16so2715150vws.0 for ; Sun, 02 Oct 2011 02:26:15 -0700 (PDT) In-Reply-To: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Bastien Guerry Cc: emacs-orgmode@gnu.org Sorry, didn't realized I wasn't sending email in plain text. On Sat, Oct 1, 2011 at 3:14 PM, netty hacky wrote: > > Hi Bastien, > > I found a third problem of org-agenda-bulk-mark-regexp, it does not work = well on daily/weekly agenda view.=A0 Basically it chokes on lines that is n= ot 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 versio= n 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) > =A0 "Mark entries match REGEXP." > =A0 (interactive "sMark entries matching regexp: ") > =A0=A0=A0 (save-excursion > =A0=A0=A0=A0=A0 (goto-char (point-min)) > =A0=A0=A0=A0=A0 (let ((entries-marked 0)) > =A0=A0=A0=A0=A0=A0=A0 (while (not (eobp)) > =A0=A0=A0=A0=A0=A0=A0=A0=A0 (unless (and > =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 (not (get-char-pro= perty (point) 'invisible)) > =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 (not (org-get-at-b= ol 'org-agenda-diary-link)) > =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 (org-get-at-bol 'o= rg-hd-marker) > =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 (let (txt-property= ) > =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 (setq txt-pr= operty (get-char-property (point) 'txt)) > =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 (string-matc= h regexp txt-property)) > =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 (not (call-interac= tively 'org-agenda-bulk-mark)) > =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 (setq entries-mark= ed (+ entries-marked 1))) > =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 (beginning-of-line 2))) > =A0=A0=A0=A0=A0=A0=A0 (if (zerop entries-marked) > =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 (message "No entry matching this regexp= .") > =A0=A0=A0=A0=A0=A0=A0=A0=A0 (message "%d entries marked for bulk action" = entries-marked))))) > > Thanks, > Net > > On Sat, Oct 1, 2011 at 12:38 AM, netty hacky wrot= e: >> >> Hi Bastien, >> >> I'm having two problems with the % command (org-agenda-bulk-mark-regexp)= in Org-mode agenda view. >> >> 1.=A0 If I use "." as the search string, I get "Wrong type argument: num= ber-or-marker-p, nil".=A0 And my workaround is to change the line "(let (en= tries-marked)" in org-agenda.el to "(let ((entries-marked 0))". >> >> 2. If I use ".*" as the search string, I get "Wrong type argument: strin= gp, nil".=A0 After some edebugging, I found the reason is that in org-agend= a-bulk-mark-regexp, re-search-forward moved the point to the end of the lin= e (since ".*" matches the whole line), causing (get-text-property (point) '= txt) to return nil, in turn caused string-match to throw the error.=A0 I th= ink this may happen to other regexps, as long as the strings matched includ= e the last character in the line.=A0 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=A0 : GNU Emacs 23.3.1 (x86_64-apple-darwin10.8.0) >> Package: Org-mode version 7.7 >> >> Thanks, >> Net >> >