From mboxrd@z Thu Jan 1 00:00:00 1970 From: Madan Ramakrishnan Subject: Re: [PATCH] Agenda: Fix org-agenda-bulk-toggle when point is at already marked item Date: Mon, 16 Apr 2012 08:07:04 -0400 Message-ID: References: <17813.1334558185@alphaville> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=20cf305640670e621504bdcaa902 Return-path: Received: from eggs.gnu.org ([208.118.235.92]:56674) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SJki8-0005V3-Mn for emacs-orgmode@gnu.org; Mon, 16 Apr 2012 08:07:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SJki1-0004ce-Vk for emacs-orgmode@gnu.org; Mon, 16 Apr 2012 08:07:12 -0400 Received: from mail-gx0-f169.google.com ([209.85.161.169]:51434) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SJki1-0004cN-Mt for emacs-orgmode@gnu.org; Mon, 16 Apr 2012 08:07:05 -0400 Received: by ggeq1 with SMTP id q1so2798006gge.0 for ; Mon, 16 Apr 2012 05:07:04 -0700 (PDT) In-Reply-To: <17813.1334558185@alphaville> 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: nicholas.dokos@hp.com Cc: emacs-orgmode@gnu.org --20cf305640670e621504bdcaa902 Content-Type: text/plain; charset=ISO-8859-1 Hi Nick, Ah, of course, you're right; it would result in a change in behavior. While I can certainly tweak the patch to maintain the old behavior in the case of a negative or zero arg, stepping back, I don't quite understand the reasoning for the current behavior. If a user has gone to the trouble of providing a negative arg, it doesn't seem intuitive that org-agenda-bulk-mark just does the same thing as if no negative arg was passed in. For what it's worth, the only caller that I see for this function in the codebase is the one in org-agenda-bulk-toggle that I was aiming to fix with this patch. Of course there could be folks relying on the current behavior, but I'd be curious as to what they're looking to do. Madan R. On Mon, Apr 16, 2012 at 2:36 AM, Nick Dokos wrote: > Madan Ramakrishnan wrote: > > > * lisp/org-agenda.el (org-agenda-bulk-mark): truly make arg optional > > as advertised by the function > > > > Problem here was that org-agenda-bulk-toggle calls org-agenda-bulk-mark > > with no parameters; however, the (max arg 1) call inside > > org-agenda-bulk-mark > > will fail with no parameter. Change the max to an or and all is well. > > > > This is my first patch for org so apologies for any inadvertent missteps > > > > TINYCHANGE > > --- > > lisp/org-agenda.el | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el > > index 0ffaadb..4e9473d 100644 > > --- a/lisp/org-agenda.el > > +++ b/lisp/org-agenda.el > > @@ -8299,7 +8299,7 @@ This is a command that has to be installed in > > `calendar-mode-map'." > > (defun org-agenda-bulk-mark (&optional arg) > > "Mark the entry at point for future bulk action." > > (interactive "p") > > - (dotimes (i (max arg 1)) > > + (dotimes (i (or arg 1)) > > (unless (org-get-at-bol 'org-agenda-diary-link) > > (let* ((m (org-get-at-bol 'org-hd-marker)) > > ov) > > -- > > 1.7.9.2 > > > > I presume arg can be negative or zero. > > If arg is e.g. -3 > > (max arg 1) -> 1 > (or arg 1) -> -3 > > so your patch changes the behavior of the function > in these cases. > > Nick > --20cf305640670e621504bdcaa902 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
Hi Nick,
=A0 Ah, of course, you're right; it would resul= t in a change in behavior. =A0
=A0 While I can certainly tweak th= e patch to maintain the old behavior in the case of a negative or zero arg,= stepping back, I don't quite understand the reasoning for the current = behavior. =A0If a user has gone to the trouble of providing a negative arg,= it doesn't seem intuitive that org-agenda-bulk-mark just does the same= thing as if no negative arg was passed in.
=A0 For what it's worth, the only caller that I see for this funct= ion in the codebase is the one in org-agenda-bulk-toggle that I was aiming = to fix with this patch. =A0Of course there could be folks relying on the cu= rrent behavior, but I'd be curious as to what they're looking to do= .

Madan R.

On Mon, Apr 16, 2012 at 2:36 AM, Nick Dokos <nicholas.dokos@hp.com> = wrote:
Mada= n Ramakrishnan <madanr79@gmail.com= > wrote:

> * lisp/org-agenda.el (org-agenda-bulk-mark): truly make arg optional > as advertised by the function
>
> Problem here was that org-agenda-bulk-toggle calls org-agenda-bulk-mar= k
> with no parameters; however, the (max arg 1) call inside
> org-agenda-bulk-mark
> will fail with no parameter. =A0Change the max to an or and all is wel= l.
>
> This is my first patch for org so apologies for any inadvertent misste= ps
>
> TINYCHANGE
> ---
> =A0lisp/org-agenda.el | =A0 =A02 +-
> =A01 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
> index 0ffaadb..4e9473d 100644
> --- a/lisp/org-agenda.el
> +++ b/lisp/org-agenda.el
> @@ -8299,7 +8299,7 @@ This is a command that has to be installed in > `calendar-mode-map'."
> =A0(defun org-agenda-bulk-mark (&optional arg)
> =A0 =A0"Mark the entry at point for future bulk action."
> =A0 =A0(interactive "p")
> - =A0(dotimes (i (max arg 1))
> + =A0(dotimes (i (or arg 1))
> =A0 =A0 =A0(unless (org-get-at-bol 'org-agenda-diary-link)
> =A0 =A0 =A0 =A0(let* ((m (org-get-at-bol 'org-hd-marker))
> =A0 =A0 =A0 ov)
> --
> 1.7.9.2
>

I presume arg can be negative or zero.

If arg is e.g. -3

(max arg 1) -> 1
(or arg 1) =A0-> -3

so your patch changes the behavior of the function
in these cases.

Nick

--20cf305640670e621504bdcaa902--