emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] Agenda: Fix org-agenda-bulk-toggle when point is at already marked item
@ 2012-04-16  2:29 Madan Ramakrishnan
  2012-04-16  6:36 ` Nick Dokos
  2012-04-20 12:55 ` Bastien
  0 siblings, 2 replies; 5+ messages in thread
From: Madan Ramakrishnan @ 2012-04-16  2:29 UTC (permalink / raw)
  To: emacs-orgmode

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

* 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

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

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

* Re: [PATCH] Agenda: Fix org-agenda-bulk-toggle when point is at already marked item
  2012-04-16  2:29 [PATCH] Agenda: Fix org-agenda-bulk-toggle when point is at already marked item Madan Ramakrishnan
@ 2012-04-16  6:36 ` Nick Dokos
  2012-04-16 12:07   ` Madan Ramakrishnan
  2012-04-20 12:55 ` Bastien
  1 sibling, 1 reply; 5+ messages in thread
From: Nick Dokos @ 2012-04-16  6:36 UTC (permalink / raw)
  To: Madan Ramakrishnan; +Cc: emacs-orgmode

Madan 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-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

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

* Re: [PATCH] Agenda: Fix org-agenda-bulk-toggle when point is at already marked item
  2012-04-16  6:36 ` Nick Dokos
@ 2012-04-16 12:07   ` Madan Ramakrishnan
  2012-04-16 14:07     ` Nick Dokos
  0 siblings, 1 reply; 5+ messages in thread
From: Madan Ramakrishnan @ 2012-04-16 12:07 UTC (permalink / raw)
  To: nicholas.dokos; +Cc: emacs-orgmode

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

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 <nicholas.dokos@hp.com> wrote:

> Madan 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-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
>

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

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

* Re: [PATCH] Agenda: Fix org-agenda-bulk-toggle when point is at already marked item
  2012-04-16 12:07   ` Madan Ramakrishnan
@ 2012-04-16 14:07     ` Nick Dokos
  0 siblings, 0 replies; 5+ messages in thread
From: Nick Dokos @ 2012-04-16 14:07 UTC (permalink / raw)
  To: Madan Ramakrishnan; +Cc: emacs-orgmode

Madan Ramakrishnan <madanr79@gmail.com> wrote:

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

You are probably right and there probably is nobody who depends on
the current behavior, but you never know for sure: that's the tyranny
of backward compatibility. I'm certainly not using it in any strange
way, so it's fine with me either way: I just wanted to point out the
possibility.

Nick

> Madan R.
> 
> On Mon, Apr 16, 2012 at 2:36 AM, Nick Dokos <nicholas.dokos@hp.com> wrote:
> 
>     Madan 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-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
> 
> 
> ----------------------------------------------------
> Alternatives:
> 
> ----------------------------------------------------

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

* Re: [PATCH] Agenda: Fix org-agenda-bulk-toggle when point is at already marked item
  2012-04-16  2:29 [PATCH] Agenda: Fix org-agenda-bulk-toggle when point is at already marked item Madan Ramakrishnan
  2012-04-16  6:36 ` Nick Dokos
@ 2012-04-20 12:55 ` Bastien
  1 sibling, 0 replies; 5+ messages in thread
From: Bastien @ 2012-04-20 12:55 UTC (permalink / raw)
  To: Madan Ramakrishnan; +Cc: emacs-orgmode

Hi Madan,

Madan Ramakrishnan <madanr79@gmail.com> writes:

> * lisp/org-agenda.el (org-agenda-bulk-mark): truly make arg optional
> as advertised by the function

applied, thanks.

> This is my first patch for org so apologies for any inadvertent
> missteps

This is good, but please use plain text emails if possible.

Nick Dokos <nicholas.dokos@hp.com> writes:

> I presume arg can be negative or zero.

A value of arg below 1 doesn't make sense: arg drives the number of 
entries that will be marked, so users usually use this for arg > 1.
If (arg < 1) then the function should trigger an error, which it does.

Best,

-- 
 Bastien

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

end of thread, other threads:[~2012-04-20 12:54 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-16  2:29 [PATCH] Agenda: Fix org-agenda-bulk-toggle when point is at already marked item Madan Ramakrishnan
2012-04-16  6:36 ` Nick Dokos
2012-04-16 12:07   ` Madan Ramakrishnan
2012-04-16 14:07     ` Nick Dokos
2012-04-20 12:55 ` Bastien

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