emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] Add option to automatically align tags in agenda view
@ 2017-08-07 13:56 Adam Porter
  2017-08-07 17:32 ` Kyle Meyer
  0 siblings, 1 reply; 9+ messages in thread
From: Adam Porter @ 2017-08-07 13:56 UTC (permalink / raw)
  To: emacs-orgmode

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

Hi Nicolas,

Here is a patch to optionally automatically align tags in the agenda
view to the right edge of the window.  I don't yet have the CA done, but
I think this qualifies as a tinychange.

Thanks,
Adam


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Patch --]
[-- Type: text/x-diff, Size: 2205 bytes --]

From 8cd0a4035ddb8fcd90d6011c9fd529526472b379 Mon Sep 17 00:00:00 2001
From: Adam Porter <adam@alphapapa.net>
Date: Mon, 7 Aug 2017 08:50:26 -0500
Subject: [PATCH] org-agenda.el: Add option to automatically align tags in
 agenda

(org-agenda-align-tags): Handle automatic alignment
(org-agenda-tags-column): Add 'auto setting

TINYCHANGE
---
 lisp/org-agenda.el | 22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index c8097de..52cbea0 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -1886,13 +1886,19 @@ When this is the symbol `prefix', only remove tags when
 (defvaralias 'org-agenda-remove-tags-when-in-prefix
   'org-agenda-remove-tags)
 
-(defcustom org-agenda-tags-column -80
+(defcustom org-agenda-tags-column 'auto
   "Shift tags in agenda items to this column.
-If this number is positive, it specifies the column.  If it is negative,
-it means that the tags should be flushright to that column.  For example,
--80 works well for a normal 80 character screen."
+If set to `auto', tags will be automatically aligned to the right
+edge of the window.
+
+If set to a positive number, tags will be left-aligned to that
+column.  If set to a negative number, tags will be right-aligned
+to that column.  For example, -80 works well for a normal 80
+character screen."
   :group 'org-agenda-line-format
-  :type 'integer)
+  :type '(choice
+	  (const :tag "Automatically align to right edge of window" auto)
+	  (integer :tag "Specific column" -80)))
 
 (defvaralias 'org-agenda-align-tags-to-column 'org-agenda-tags-column)
 
@@ -8959,7 +8965,11 @@ If FORCE-TAGS is non nil, the car of it returns the new tags."
 
 (defun org-agenda-align-tags (&optional line)
   "Align all tags in agenda items to `org-agenda-tags-column'."
-  (let ((inhibit-read-only t) l c)
+  (let ((inhibit-read-only t)
+	(org-agenda-tags-column (pcase org-agenda-tags-column
+				  ('auto (- (window-text-width)))
+				  (otherwise org-agenda-tags-column)))
+	l c)
     (save-excursion
       (goto-char (if line (point-at-bol) (point-min)))
       (while (re-search-forward "\\([ \t]+\\)\\(:[[:alnum:]_@#%:]+:\\)[ \t]*$"
-- 
2.7.4


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

* Re: [PATCH] Add option to automatically align tags in agenda view
  2017-08-07 13:56 [PATCH] Add option to automatically align tags in agenda view Adam Porter
@ 2017-08-07 17:32 ` Kyle Meyer
  2017-08-07 18:57   ` Adam Porter
  0 siblings, 1 reply; 9+ messages in thread
From: Kyle Meyer @ 2017-08-07 17:32 UTC (permalink / raw)
  To: Adam Porter, emacs-orgmode

Adam Porter <adam@alphapapa.net> writes:

[...]

> +	(org-agenda-tags-column (pcase org-agenda-tags-column
> +				  ('auto (- (window-text-width)))

I believe that `auto is needed instead of 'auto because the latter will
fail with Emacs versions earlier than Emacs 25.  Though ...

> +				  (otherwise org-agenda-tags-column)))

... with just one case and a fallthrough, I'd prefer you test with eq
rather than using pcase.

-- 
Kyle

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

* Re: [PATCH] Add option to automatically align tags in agenda view
  2017-08-07 17:32 ` Kyle Meyer
@ 2017-08-07 18:57   ` Adam Porter
  2017-08-07 22:04     ` Kyle Meyer
  0 siblings, 1 reply; 9+ messages in thread
From: Adam Porter @ 2017-08-07 18:57 UTC (permalink / raw)
  To: emacs-orgmode

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

Kyle Meyer <kyle@kyleam.com> writes:

> ... with just one case and a fallthrough, I'd prefer you test with eq
> rather than using pcase.

Hi Kyle,

Ok, I've updated the patch.

Thanks,
Adam

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch --]
[-- Type: text/x-diff, Size: 2195 bytes --]

From 99a61e09d5267ddaa84e8f93fbab161144aea011 Mon Sep 17 00:00:00 2001
From: Adam Porter <adam@alphapapa.net>
Date: Mon, 7 Aug 2017 08:50:26 -0500
Subject: [PATCH] org-agenda.el: Add option to automatically align tags in
 agenda

(org-agenda-align-tags): Handle automatic alignment
(org-agenda-tags-column): Add 'auto setting

TINYCHANGE
---
 lisp/org-agenda.el | 22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index c8097de..76282d4 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -1886,13 +1886,19 @@ When this is the symbol `prefix', only remove tags when
 (defvaralias 'org-agenda-remove-tags-when-in-prefix
   'org-agenda-remove-tags)
 
-(defcustom org-agenda-tags-column -80
+(defcustom org-agenda-tags-column 'auto
   "Shift tags in agenda items to this column.
-If this number is positive, it specifies the column.  If it is negative,
-it means that the tags should be flushright to that column.  For example,
--80 works well for a normal 80 character screen."
+If set to `auto', tags will be automatically aligned to the right
+edge of the window.
+
+If set to a positive number, tags will be left-aligned to that
+column.  If set to a negative number, tags will be right-aligned
+to that column.  For example, -80 works well for a normal 80
+character screen."
   :group 'org-agenda-line-format
-  :type 'integer)
+  :type '(choice
+	  (const :tag "Automatically align to right edge of window" auto)
+	  (integer :tag "Specific column" -80)))
 
 (defvaralias 'org-agenda-align-tags-to-column 'org-agenda-tags-column)
 
@@ -8959,7 +8965,11 @@ If FORCE-TAGS is non nil, the car of it returns the new tags."
 
 (defun org-agenda-align-tags (&optional line)
   "Align all tags in agenda items to `org-agenda-tags-column'."
-  (let ((inhibit-read-only t) l c)
+  (let ((inhibit-read-only t)
+	(org-agenda-tags-column (if (eq 'auto org-agenda-tags-column)
+				    (- (window-text-width))
+				  org-agenda-tags-column))
+	l c)
     (save-excursion
       (goto-char (if line (point-at-bol) (point-min)))
       (while (re-search-forward "\\([ \t]+\\)\\(:[[:alnum:]_@#%:]+:\\)[ \t]*$"
-- 
2.7.4


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

* Re: [PATCH] Add option to automatically align tags in agenda view
  2017-08-07 18:57   ` Adam Porter
@ 2017-08-07 22:04     ` Kyle Meyer
  2017-08-08 15:52       ` Adam Porter
  0 siblings, 1 reply; 9+ messages in thread
From: Kyle Meyer @ 2017-08-07 22:04 UTC (permalink / raw)
  To: Adam Porter, emacs-orgmode

Adam Porter <adam@alphapapa.net> writes:

> Ok, I've updated the patch.

Thanks.  A few more comments.

> (org-agenda-align-tags): Handle automatic alignment
> (org-agenda-tags-column): Add 'auto setting

You're missing the file name in the entries above.  Also, the entries
should end in a period.

> -(defcustom org-agenda-tags-column -80
> +(defcustom org-agenda-tags-column 'auto
>    "Shift tags in agenda items to this column.
> -If this number is positive, it specifies the column.  If it is negative,
> -it means that the tags should be flushright to that column.  For example,
> --80 works well for a normal 80 character screen."
> +If set to `auto', tags will be automatically aligned to the right
> +edge of the window.
> +
> +If set to a positive number, tags will be left-aligned to that
> +column.  If set to a negative number, tags will be right-aligned
> +to that column.  For example, -80 works well for a normal 80
> +character screen."
>    :group 'org-agenda-line-format
> -  :type 'integer)
> +  :type '(choice
> +	  (const :tag "Automatically align to right edge of window" auto)
> +	  (integer :tag "Specific column" -80)))

Since you're changing the default value, shouldn't you add appropriate
values for the :version and :package-version keywords?

It'd be good to mention this change in ORG-NEWS as well.

-- 
Kyle

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

* Re: [PATCH] Add option to automatically align tags in agenda view
  2017-08-07 22:04     ` Kyle Meyer
@ 2017-08-08 15:52       ` Adam Porter
  2017-08-08 18:19         ` Kyle Meyer
  0 siblings, 1 reply; 9+ messages in thread
From: Adam Porter @ 2017-08-08 15:52 UTC (permalink / raw)
  To: emacs-orgmode

Kyle Meyer <kyle@kyleam.com> writes:

>> (org-agenda-align-tags): Handle automatic alignment
>> (org-agenda-tags-column): Add 'auto setting
>
> You're missing the file name in the entries above.  Also, the entries
> should end in a period.

Oops, fixed.

> Since you're changing the default value, shouldn't you add appropriate
> values for the :version and :package-version keywords?

Thanks, I didn't know about these.  I set :package-version to 9.1, since
that should be the next Org release, I guess.  I set :version to 26.3
since I guess that will be the next Emacs release, although I don't know
if it will include Org 9.1.  Let me know if these need to be changed.

> It'd be good to mention this change in ORG-NEWS as well.

I should have thought of that.  Done.

I don't know if this still technically qualifies as a tinychange.  I've
sent the email to request the CA form just in case.

Thanks.

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

* Re: [PATCH] Add option to automatically align tags in agenda view
  2017-08-08 15:52       ` Adam Porter
@ 2017-08-08 18:19         ` Kyle Meyer
  2017-08-08 18:23           ` Kyle Meyer
  2017-08-08 18:42           ` Adam Porter
  0 siblings, 2 replies; 9+ messages in thread
From: Kyle Meyer @ 2017-08-08 18:19 UTC (permalink / raw)
  To: Adam Porter, emacs-orgmode

Adam Porter <adam@alphapapa.net> writes:

> Kyle Meyer <kyle@kyleam.com> writes:

[...]

>> Since you're changing the default value, shouldn't you add appropriate
>> values for the :version and :package-version keywords?
>
> Thanks, I didn't know about these.  I set :package-version to 9.1, since
> that should be the next Org release, I guess.

Yep, master-only changes are using 9.1 for :package-version

    $ git log -u -G":package-version" maint..master

> I set :version to 26.3 since I guess that will be the next Emacs
> release, although I don't know if it will include Org 9.1.  Let me
> know if these need to be changed.

As you can see in the diffs above, master-only changes are using 26.1
for :version.  Assuming Org 9.0.* ships with Emacs 26.1, these will be
wrong, but they can be updated all together once 26.2 is released.

>> It'd be good to mention this change in ORG-NEWS as well.
>
> I should have thought of that.  Done.

Thanks.  Did you forget to attach the patch?

> I don't know if this still technically qualifies as a tinychange.  I've
> sent the email to request the CA form just in case.

I don't know either.  How about I apply your *.el changes, and we can
update ORG-NEWS once your assignment comes through?

-- 
Kyle

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

* Re: [PATCH] Add option to automatically align tags in agenda view
  2017-08-08 18:19         ` Kyle Meyer
@ 2017-08-08 18:23           ` Kyle Meyer
  2017-08-08 18:42           ` Adam Porter
  1 sibling, 0 replies; 9+ messages in thread
From: Kyle Meyer @ 2017-08-08 18:23 UTC (permalink / raw)
  To: Adam Porter, emacs-orgmode

Kyle Meyer <kyle@kyleam.com> writes:

> As you can see in the diffs above, master-only changes are using 26.1
> for :version.  Assuming Org 9.0.* ships with Emacs 26.1, these will be
> wrong, but they can be updated all together once 26.2 is released.
                                                   ^^^^
                                              Doh, 26.1
-- 
Kyle

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

* Re: [PATCH] Add option to automatically align tags in agenda view
  2017-08-08 18:19         ` Kyle Meyer
  2017-08-08 18:23           ` Kyle Meyer
@ 2017-08-08 18:42           ` Adam Porter
  2017-08-08 19:26             ` Kyle Meyer
  1 sibling, 1 reply; 9+ messages in thread
From: Adam Porter @ 2017-08-08 18:42 UTC (permalink / raw)
  To: emacs-orgmode

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

Kyle Meyer <kyle@kyleam.com> writes:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch --]
[-- Type: text/x-diff, Size: 2991 bytes --]

From ea3007a8b35d727f71860bd7697808f90d5e1e66 Mon Sep 17 00:00:00 2001
From: Adam Porter <adam@alphapapa.net>
Date: Mon, 7 Aug 2017 08:50:26 -0500
Subject: [PATCH] org-agenda.el: Add option to automatically align tags in
 agenda

* lisp/org-agenda.el:
  (org-agenda-tags-column): Add 'auto setting.
  (org-agenda-align-tags): Handle automatic alignment.

* etc/ORG-NEWS: Document this new setting.

TINYCHANGE
---
 etc/ORG-NEWS       |  4 ++++
 lisp/org-agenda.el | 24 ++++++++++++++++++------
 2 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 6361923..0aa0844 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -112,6 +112,10 @@ docstrings.
 **** New variable : ~org-deadline-past-days~
 See docstring for details.
 **** Binding C-c C-x < for ~org-agenda-set-restriction-lock-from-agenda~
+**** New auto-align default setting for =org-agenda-tags-column=
+
+=org-agenda-tags-column= can now be set to ='auto=, which will automatically align tags to the right edge of the window.  This is now the default setting.
+
 *** New value for ~org-publish-sitemap-sort-folders~
 
 The new ~ignore~ value effectively allows toggling inclusion of
diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index c8097de..93148d0 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -1886,13 +1886,21 @@ When this is the symbol `prefix', only remove tags when
 (defvaralias 'org-agenda-remove-tags-when-in-prefix
   'org-agenda-remove-tags)
 
-(defcustom org-agenda-tags-column -80
+(defcustom org-agenda-tags-column 'auto
   "Shift tags in agenda items to this column.
-If this number is positive, it specifies the column.  If it is negative,
-it means that the tags should be flushright to that column.  For example,
--80 works well for a normal 80 character screen."
+If set to `auto', tags will be automatically aligned to the right
+edge of the window.
+
+If set to a positive number, tags will be left-aligned to that
+column.  If set to a negative number, tags will be right-aligned
+to that column.  For example, -80 works well for a normal 80
+character screen."
   :group 'org-agenda-line-format
-  :type 'integer)
+  :type '(choice
+	  (const :tag "Automatically align to right edge of window" auto)
+	  (integer :tag "Specific column" -80))
+  :package-version '(Org . "9.1")
+  :version "26.1")
 
 (defvaralias 'org-agenda-align-tags-to-column 'org-agenda-tags-column)
 
@@ -8959,7 +8967,11 @@ If FORCE-TAGS is non nil, the car of it returns the new tags."
 
 (defun org-agenda-align-tags (&optional line)
   "Align all tags in agenda items to `org-agenda-tags-column'."
-  (let ((inhibit-read-only t) l c)
+  (let ((inhibit-read-only t)
+	(org-agenda-tags-column (if (eq 'auto org-agenda-tags-column)
+				    (- (window-text-width))
+				  org-agenda-tags-column))
+	l c)
     (save-excursion
       (goto-char (if line (point-at-bol) (point-min)))
       (while (re-search-forward "\\([ \t]+\\)\\(:[[:alnum:]_@#%:]+:\\)[ \t]*$"
-- 
2.7.4


[-- Attachment #3: Type: text/plain, Size: 693 bytes --]


> As you can see in the diffs above, master-only changes are using 26.1
> for :version.  Assuming Org 9.0.* ships with Emacs 26.1, these will be
> wrong, but they can be updated all together once 26.2 is released.

I have been getting my numbers mixed up.  :)  Fixed.

> Thanks.  Did you forget to attach the patch?

Yes.  :(

But not this time!

>> I don't know if this still technically qualifies as a tinychange.  I've
>> sent the email to request the CA form just in case.
>
> I don't know either.  How about I apply your *.el changes, and we can
> update ORG-NEWS once your assignment comes through?

Sure.  Thanks for your patience.  Please let me know if any other
changes are needed.

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

* Re: [PATCH] Add option to automatically align tags in agenda view
  2017-08-08 18:42           ` Adam Porter
@ 2017-08-08 19:26             ` Kyle Meyer
  0 siblings, 0 replies; 9+ messages in thread
From: Kyle Meyer @ 2017-08-08 19:26 UTC (permalink / raw)
  To: Adam Porter, emacs-orgmode

> Kyle Meyer <kyle@kyleam.com> writes:

>>> I don't know if this still technically qualifies as a tinychange.  I've
>>> sent the email to request the CA form just in case.
>>
>> I don't know either.  How about I apply your *.el changes, and we can
>> update ORG-NEWS once your assignment comes through?

On second thought (and counting lines with new content), I think the
entire patch is OK as a tinychange.  Applied to master with minor
formatting tweaks to the log message and NEWS entry.

I've added you to http://orgmode.org/worg/org-contribute.html under the
"processing assignment" section.

Thanks.

-- 
Kyle

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

end of thread, other threads:[~2017-08-08 19:26 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-07 13:56 [PATCH] Add option to automatically align tags in agenda view Adam Porter
2017-08-07 17:32 ` Kyle Meyer
2017-08-07 18:57   ` Adam Porter
2017-08-07 22:04     ` Kyle Meyer
2017-08-08 15:52       ` Adam Porter
2017-08-08 18:19         ` Kyle Meyer
2017-08-08 18:23           ` Kyle Meyer
2017-08-08 18:42           ` Adam Porter
2017-08-08 19:26             ` Kyle Meyer

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