summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Porter <adam@alphapapa.net>2017-08-07 08:50:26 -0500
committerKyle Meyer <kyle@kyleam.com>2017-08-08 15:18:50 -0400
commit7e46af419cfab3ccdf5dd4f6dea02e3c1293c352 (patch)
treee603bfef75e89892656905b26ff354ccae82071e
parentf1b2a95bee6695ffe5b65200990d3b6a17ddd4c4 (diff)
downloadorg-mode-7e46af419cfab3ccdf5dd4f6dea02e3c1293c352.tar.gz
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. TINYCHANGE
-rw-r--r--etc/ORG-NEWS6
-rw-r--r--lisp/org-agenda.el24
2 files changed, 24 insertions, 6 deletions
diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 6361923..451c9c6 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -112,6 +112,12 @@ 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]*$"