Re: new feature for consideration: other-tab for org-agenda-window-setup

2020-09-04 Thread Eric S Fraga
On Friday,  4 Sep 2020 at 09:06, Bastien wrote:
> Er, now I see, sorry for the overlook!

No worries!  I did forget to do this in the initial patch.  Thank you.

-- 
: Eric S Fraga via Emacs 28.0.50, Org release_9.3.7-725-g7bc18e



Re: new feature for consideration: other-tab for org-agenda-window-setup

2020-09-04 Thread Bastien
Hi Eric,

Eric S Fraga  writes:

> On Thursday,  3 Sep 2020 at 14:29, Bastien wrote:
>> IMHO it deserves a small addition to etc/ORG-NEWS.
>
> Already there although maybe I added it in the wrong section?  I put it
> under Version 9.4 -> New options.

Er, now I see, sorry for the overlook!

-- 
 Bastien



Re: new feature for consideration: other-tab for org-agenda-window-setup

2020-09-03 Thread Eric S Fraga
On Thursday,  3 Sep 2020 at 14:29, Bastien wrote:
> IMHO it deserves a small addition to etc/ORG-NEWS.

Already there although maybe I added it in the wrong section?  I put it
under Version 9.4 -> New options.

-- 
: Eric S Fraga via Emacs 28.0.50, Org release_9.3.7-725-g7bc18e



Re: new feature for consideration: other-tab for org-agenda-window-setup

2020-09-03 Thread Kyle Meyer
Bastien writes:

> Hi again,
>
> Eric S Fraga  writes:
>
>> Patch attached.  Comments welcome, of course.
>
> IMHO it deserves a small addition to etc/ORG-NEWS.
>
> Can one of you add it?

v2 (87imd33mys@ucl.ac.uk) included a NEWS entry.



Re: new feature for consideration: other-tab for org-agenda-window-setup

2020-09-03 Thread Bastien
Hi again,

Eric S Fraga  writes:

> Patch attached.  Comments welcome, of course.

IMHO it deserves a small addition to etc/ORG-NEWS.

Can one of you add it?

-- 
 Bastien



Re: new feature for consideration: other-tab for org-agenda-window-setup

2020-09-03 Thread Bastien
Kyle Meyer  writes:

> Kyle Meyer writes:
>
>> I'll let this sit for another day to see if other comments come in.
>
> Applied (e8ebf5d6c).

A welcome enhancement - thanks Eric and Kyle!

-- 
 Bastien



Re: new feature for consideration: other-tab for org-agenda-window-setup

2020-08-31 Thread Eric S Fraga
On Saturday, 29 Aug 2020 at 08:07, Kyle Meyer wrote:
> Applied (e8ebf5d6c).

Thank you.

-- 
: Eric S Fraga via Emacs 28.0.50, Org release_9.3.7-720-gbe5916



Re: new feature for consideration: other-tab for org-agenda-window-setup

2020-08-29 Thread Kyle Meyer
Kyle Meyer writes:

> I'll let this sit for another day to see if other comments come in.

Applied (e8ebf5d6c).



Re: new feature for consideration: other-tab for org-agenda-window-setup

2020-08-27 Thread Kyle Meyer
Eric S Fraga writes:

> Dear all,
>
> Please see attached for a new version of my changes for adding
> 'other-tab as an option for org-agenda-window-setup.
>
> I think I've addressed all your comments, Kyle, but any more are
> welcome.  It would be good if somebody who is using an older version of
> Emacs, i.e. pre 27.1, could test the error handling: set
> org-agenda-window-setup to 'other-tab and see if it fails properly.  I
> only have v28.x on my systems!
>
> On v28.x, it seems to be working fine.

Thanks for the updated patch.  I've tested it on 26.3 as well as the
Emacs master branch.

> @@ -3769,6 +3776,10 @@ FILTER-ALIST is an alist of filters we need to apply 
> when
>(org-switch-to-buffer-other-window abuf))
>   ((eq org-agenda-window-setup 'other-frame)
>(switch-to-buffer-other-frame abuf))
> + ((eq org-agenda-window-setup 'other-tab)
> +  (if (fboundp 'switch-to-buffer-other-tab)
> +   (switch-to-buffer-other-tab abuf)
> + (user-error "Your version of Emacs does not have tab bar support.")))

Sorry, I've got another consistency/style nit-pick for you: the
convention is to omit the trailing period from error messages.  (No need
to resend for that.  I'll plan to adjust when applying.)

I'll let this sit for another day to see if other comments come in.



Re: new feature for consideration: other-tab for org-agenda-window-setup

2020-08-27 Thread Eric S Fraga
Dear all,

Please see attached for a new version of my changes for adding
'other-tab as an option for org-agenda-window-setup.

I think I've addressed all your comments, Kyle, but any more are
welcome.  It would be good if somebody who is using an older version of
Emacs, i.e. pre 27.1, could test the error handling: set
org-agenda-window-setup to 'other-tab and see if it fails properly.  I
only have v28.x on my systems!

On v28.x, it seems to be working fine.

thank you,
eric

-- 
: Eric S Fraga via Emacs 28.0.50, Org release_9.3.7-720-gbe5916
>From be5916aba7031cd2343d3e59a98a47496ced95f2 Mon Sep 17 00:00:00 2001
From: Eric S Fraga 
Date: Wed, 26 Aug 2020 17:17:42 +0100
Subject: [PATCH] Add other-tab option for org-agenda-window-setup

* org-agenda.el (org-agenda-prepare-window, org-agenda--quit): Handle
other-tab option for agenda view creation and exit.
---
 etc/ORG-NEWS   |  6 ++
 lisp/org-agenda.el | 27 +--
 2 files changed, 27 insertions(+), 6 deletions(-)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 8a3589ec2..6d8db0e18 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -291,6 +291,12 @@ possible via column view value edit or with ==.
 Counterpart of ~org-show-entry~.
 
 ** New options
+*** New option for using tabs in ~org-agenda-window-setup~
+
+Choosing ~other-tab~ for ~org-agenda-window-setup~ will open the
+agenda view in a new tab.  This will work with versions of Emacs since
+27.1 when ~tab-bar-mode~ was introduced.
+
 *** New option ~org-clock-auto-clockout-timer~
 
 When this option is set to a number and the user configuration
diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index 8ebc882fc..fd30e6d81 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -1100,14 +1100,21 @@ reorganize-frame  Show only two windows on the current frame, the current
   window and the agenda.
 other-frame   Use `switch-to-buffer-other-frame' to display agenda.
   Also, when exiting the agenda, kill that frame.
+other-tab Use `switch-to-buffer-other-tab' to display the
+  agenda, making use of the `tab-bar-mode' introduced
+  in Emacs version 27.1.  Also, kill that tab when
+  exiting the agenda view. 
+
 See also the variable `org-agenda-restore-windows-after-quit'."
   :group 'org-agenda-windows
   :type '(choice
 	  (const current-window)
 	  (const other-frame)
+	  (const other-tab)
 	  (const other-window)
 	  (const only-window)
-	  (const reorganize-frame)))
+	  (const reorganize-frame))
+  :package-version '(Org . "9.4"))
 
 (defcustom org-agenda-window-frame-fractions '(0.5 . 0.75)
   "The min and max height of the agenda window as a fraction of frame height.
@@ -1118,11 +1125,11 @@ It only matters if `org-agenda-window-setup' is `reorganize-frame'."
 
 (defcustom org-agenda-restore-windows-after-quit nil
   "Non-nil means restore window configuration upon exiting agenda.
-Before the window configuration is changed for displaying the agenda,
-the current status is recorded.  When the agenda is exited with
-`q' or `x' and this option is set, the old state is restored.  If
-`org-agenda-window-setup' is `other-frame', the value of this
-option will be ignored."
+Before the window configuration is changed for displaying the
+agenda, the current status is recorded.  When the agenda is
+exited with `q' or `x' and this option is set, the old state is
+restored.  If `org-agenda-window-setup' is `other-frame' or
+`other-tab', the value of this option will be ignored."
   :group 'org-agenda-windows
   :type 'boolean)
 
@@ -3769,6 +3776,10 @@ FILTER-ALIST is an alist of filters we need to apply when
   (org-switch-to-buffer-other-window abuf))
  ((eq org-agenda-window-setup 'other-frame)
   (switch-to-buffer-other-frame abuf))
+ ((eq org-agenda-window-setup 'other-tab)
+  (if (fboundp 'switch-to-buffer-other-tab)
+	  (switch-to-buffer-other-tab abuf)
+	(user-error "Your version of Emacs does not have tab bar support.")))
  ((eq org-agenda-window-setup 'only-window)
   (delete-other-windows)
   (pop-to-buffer-same-window abuf))
@@ -7389,6 +7400,10 @@ agenda."
   (cond
((eq org-agenda-window-setup 'other-frame)
 	(delete-frame))
+   ((eq org-agenda-window-setup 'other-tab)
+	(if (fboundp 'tab-bar-close-tab)
+	(tab-bar-close-tab)
+	  (user-error "Your version of Emacs does not have tab bar mode support.")))
((and org-agenda-restore-windows-after-quit
 	 wconf)
 	;; Maybe restore the pre-agenda window configuration.  Reset
-- 
2.28.0



Re: new feature for consideration: other-tab for org-agenda-window-setup

2020-08-27 Thread Kyle Meyer
Eric S Fraga writes:

> On Wednesday, 26 Aug 2020 at 18:28, Kyle Meyer wrote:
>> Thanks.  Sounds fine to me.
>
> Hi Kyle,
>
> thanks for the feedback.  Some questions/comments:
>
>> Style conventions: s/added/Add/s/handle/Handle/
>
> Okay although grammatically wrong but we won't go into that... ;-)

(Eh, sorry about the lack of a space between my s/// expressions.)

I assume you're talking about using the imperative mood with the "added
=> Add" change.  I don't see what's grammatically incorrect about that.

>> I think it's worth noting here which Emacs version gained tab support.
>
> Just as part of the comment?

As part of the docstring, yes.

Also, I should have mentioned that because the option value is changing,
the defcustom should get a `:package-version '(Org . "9.N")`, where N is
probably 4.  (And of course a NEWS entry would be good.)

>> As you suggest in your follow-up message, you need to guard these calls
>> for the sake of older versions.  Perhaps something like
>>
>> (if (fboundp 'FN)
>> (FN ...)
>>   (user-error "Your Emacs version doesn't support tabs"))
>
> Okay; is there any way to guard the customization of the variable so
> that the option does not get provided when it's an older version of
> Emacs?

You could conditionally set the defcustom value, but IMO it's not really
worth the trouble.  Either way I think the above call sites should be
guarded.

Thanks.



Re: new feature for consideration: other-tab for org-agenda-window-setup

2020-08-27 Thread Eric S Fraga
On Wednesday, 26 Aug 2020 at 18:28, Kyle Meyer wrote:
> Thanks.  Sounds fine to me.

Hi Kyle,

thanks for the feedback.  Some questions/comments:

> Style conventions: s/added/Add/s/handle/Handle/

Okay although grammatically wrong but we won't go into that... ;-)

> I think it's worth noting here which Emacs version gained tab support.

Just as part of the comment?

> As you suggest in your follow-up message, you need to guard these calls
> for the sake of older versions.  Perhaps something like
>
> (if (fboundp 'FN)
> (FN ...)
>   (user-error "Your Emacs version doesn't support tabs"))

Okay; is there any way to guard the customization of the variable so that the 
option does not get provided when it's an older version of Emacs?

I'll update the patch and post later.

Thanks again,
eric

-- 
: Eric S Fraga via Emacs 28.0.50, Org release_9.3.7-719-gcdfc40.dirty



Re: new feature for consideration: other-tab for org-agenda-window-setup

2020-08-26 Thread Kyle Meyer
Eric S Fraga writes:

> Hi,
>
> for those of us using more recent versions of Emacs, the new
> tab-bar-mode can be quite useful.  As I have been playing with, I
> thought it would make sense to have the option for agenda views to
> pop-up in a new tab as an option.  I've coded something that behaves in
> a similar way to the 'other-frame option that currently exists for
> org-agenda-window-setup.
>
> Patch attached.  Comments welcome, of course.

Thanks.  Sounds fine to me.

> Subject: [PATCH] added other-tab option for org-agenda-window-setup
>
> * org-agenda.el (org-agenda-prepare-window, org-agenda--quit): handle
> other-tab option for agenda view creation and exit.

Style conventions: s/added/Add/s/handle/Handle/

> ---
>  lisp/org-agenda.el | 18 +-
>  1 file changed, 13 insertions(+), 5 deletions(-)
>
> diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
> index 8ebc882fc..abb969fe4 100644
> --- a/lisp/org-agenda.el
> +++ b/lisp/org-agenda.el
> @@ -1100,11 +1100,15 @@ reorganize-frame  Show only two windows on the 
> current frame, the current
>window and the agenda.
>  other-frame   Use `switch-to-buffer-other-frame' to display agenda.
>Also, when exiting the agenda, kill that frame.
> +other-tab Use `switch-to-buffer-other-tab' to display the agenda.
> +  Also, kill that tab when exiting the agenda view.
> +

I think it's worth noting here which Emacs version gained tab support.

>  See also the variable `org-agenda-restore-windows-after-quit'."
>:group 'org-agenda-windows
>:type '(choice
> (const current-window)
> (const other-frame)
> +   (const other-tab)
> (const other-window)
> (const only-window)
> (const reorganize-frame)))
> @@ -1118,11 +1122,11 @@ It only matters if `org-agenda-window-setup' is 
> `reorganize-frame'."
> [...]
> @@ -3769,6 +3773,8 @@ FILTER-ALIST is an alist of filters we need to apply 
> when
>(org-switch-to-buffer-other-window abuf))
>   ((eq org-agenda-window-setup 'other-frame)
>(switch-to-buffer-other-frame abuf))
> + ((eq org-agenda-window-setup 'other-tab)
> +  (switch-to-buffer-other-tab abuf))
>   ((eq org-agenda-window-setup 'only-window)
>(delete-other-windows)
>(pop-to-buffer-same-window abuf))
> @@ -7389,6 +7395,8 @@ agenda."
>(cond
> ((eq org-agenda-window-setup 'other-frame)
>   (delete-frame))
> +   ((eq org-agenda-window-setup 'other-tab)
> + (tab-bar-close-tab))
> ((and org-agenda-restore-windows-after-quit
>wconf)

As you suggest in your follow-up message, you need to guard these calls
for the sake of older versions.  Perhaps something like

(if (fboundp 'FN)
(FN ...)
  (user-error "Your Emacs version doesn't support tabs"))

in both spots.  (That will silence the byte-compiler warnings too.)



new feature for consideration: other-tab for org-agenda-window-setup

2020-08-26 Thread Eric S Fraga
Hi,

for those of us using more recent versions of Emacs, the new
tab-bar-mode can be quite useful.  As I have been playing with, I
thought it would make sense to have the option for agenda views to
pop-up in a new tab as an option.  I've coded something that behaves in
a similar way to the 'other-frame option that currently exists for
org-agenda-window-setup.

Patch attached.  Comments welcome, of course.

-- 
: Eric S Fraga via Emacs 28.0.50, Org release_9.3.7-719-gcdfc40.dirty
>From e715a495f9659a5cef39e25822e18651ecefcf32 Mon Sep 17 00:00:00 2001
From: Eric S Fraga 
Date: Wed, 26 Aug 2020 17:17:42 +0100
Subject: [PATCH] added other-tab option for org-agenda-window-setup

* org-agenda.el (org-agenda-prepare-window, org-agenda--quit): handle
other-tab option for agenda view creation and exit.
---
 lisp/org-agenda.el | 18 +-
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index 8ebc882fc..abb969fe4 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -1100,11 +1100,15 @@ reorganize-frame  Show only two windows on the current frame, the current
   window and the agenda.
 other-frame   Use `switch-to-buffer-other-frame' to display agenda.
   Also, when exiting the agenda, kill that frame.
+other-tab Use `switch-to-buffer-other-tab' to display the agenda.
+  Also, kill that tab when exiting the agenda view.
+
 See also the variable `org-agenda-restore-windows-after-quit'."
   :group 'org-agenda-windows
   :type '(choice
 	  (const current-window)
 	  (const other-frame)
+	  (const other-tab)
 	  (const other-window)
 	  (const only-window)
 	  (const reorganize-frame)))
@@ -1118,11 +1122,11 @@ It only matters if `org-agenda-window-setup' is `reorganize-frame'."
 
 (defcustom org-agenda-restore-windows-after-quit nil
   "Non-nil means restore window configuration upon exiting agenda.
-Before the window configuration is changed for displaying the agenda,
-the current status is recorded.  When the agenda is exited with
-`q' or `x' and this option is set, the old state is restored.  If
-`org-agenda-window-setup' is `other-frame', the value of this
-option will be ignored."
+Before the window configuration is changed for displaying the
+agenda, the current status is recorded.  When the agenda is
+exited with `q' or `x' and this option is set, the old state is
+restored.  If `org-agenda-window-setup' is `other-frame' or
+`other-tab', the value of this option will be ignored."
   :group 'org-agenda-windows
   :type 'boolean)
 
@@ -3769,6 +3773,8 @@ FILTER-ALIST is an alist of filters we need to apply when
   (org-switch-to-buffer-other-window abuf))
  ((eq org-agenda-window-setup 'other-frame)
   (switch-to-buffer-other-frame abuf))
+ ((eq org-agenda-window-setup 'other-tab)
+  (switch-to-buffer-other-tab abuf))
  ((eq org-agenda-window-setup 'only-window)
   (delete-other-windows)
   (pop-to-buffer-same-window abuf))
@@ -7389,6 +7395,8 @@ agenda."
   (cond
((eq org-agenda-window-setup 'other-frame)
 	(delete-frame))
+   ((eq org-agenda-window-setup 'other-tab)
+	(tab-bar-close-tab))
((and org-agenda-restore-windows-after-quit
 	 wconf)
 	;; Maybe restore the pre-agenda window configuration.  Reset
-- 
2.28.0



Re: new feature for consideration: other-tab for org-agenda-window-setup

2020-08-26 Thread Eric S Fraga
PS -advice on protecting the new code for versions of Emacs that have
tab-bar-mode would be welcome.

-- 
: Eric S Fraga via Emacs 28.0.50, Org release_9.3.7-719-gcdfc40.dirty