* [PATCH] Tag visibility fixup after setting them
@ 2016-12-27 10:30 Alexey Lebedeff
2016-12-29 0:39 ` Nicolas Goaziou
0 siblings, 1 reply; 4+ messages in thread
From: Alexey Lebedeff @ 2016-12-27 10:30 UTC (permalink / raw)
To: Orgmode Mailing List
[-- Attachment #1: Type: text/plain, Size: 176 bytes --]
Hi folks,
This fixes bug where you sometimes can't immediately see tags that were
just set. And to reveal them you need to go through global visibility
cycle.
Best,
Alexey
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Reveal-tags-after-setting-them.patch --]
[-- Type: text/x-patch, Size: 2835 bytes --]
From d81f5be08c83fb31adfd36dc97dcf92268c898ed Mon Sep 17 00:00:00 2001
From: Alexey Lebedeff <binarin@gmail.com>
Date: Sun, 25 Dec 2016 13:24:04 +0300
Subject: [PATCH] Reveal tags after setting them
Sometimes freshly added tags can be sucked into invisible outline
region (denoted by ellipsis) - and to see them you need to do the full
global visibilty cycle.
---
lisp/org.el | 11 ++++++++++-
testing/lisp/test-org.el | 18 ++++++++++++++++++
2 files changed, 28 insertions(+), 1 deletion(-)
diff --git a/lisp/org.el b/lisp/org.el
index 3ddd80b..4d6ba75 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -8003,6 +8003,15 @@ unconditionally."
(org-N-empty-lines-before-current (if blank? 1 0))))))
(run-hooks 'org-insert-heading-hook))
+(defun org-insert-visible-text (&rest args)
+ "Inserts arguments at point and makes them visible in outline.
+
+When text is being inserted on the invisible region boundary, it
+can be inadvertently sucked into invisibility."
+ (let* ((before-point (point)))
+ (apply #'insert args)
+ (outline-flag-region before-point (point) nil)))
+
(defun org-N-empty-lines-before-current (N)
"Make the number of empty lines before current exactly N.
So this will delete or add empty lines."
@@ -15096,7 +15105,7 @@ When JUST-ALIGN is non-nil, only align tags."
;; white spaces.
(end-of-line)
(if (not (equal tags ""))
- (insert " " tags)
+ (org-insert-visible-text " " tags)
(skip-chars-backward " \t")
(delete-region (point) (line-end-position)))))
;; Align tags, if any. Fix tags column if `org-indent-mode'
diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el
index bbd0c0b..d60364a 100644
--- a/testing/lisp/test-org.el
+++ b/testing/lisp/test-org.el
@@ -5130,6 +5130,24 @@ Paragraph<point>"
(should-not
(org-test-with-temp-text "Paragraph" (org-hide-block-toggle-maybe))))
+(ert-deftest test-org/fast-tag-selection ()
+ "Test `org-fast-tag-selection'."
+ ;; Tags set via fast-tag-selection should be visible afterwards
+ (should
+ (let ((org-tag-alist '(("NEXT" . ?n)))
+ (org-fast-tag-selection-single-key t))
+ (cl-letf (((symbol-function 'read-char-exclusive) (lambda () ?n))
+ ((symbol-function 'window-width) (lambda (&rest args) 100)))
+ (org-test-with-temp-text "<point>* Headline\nAnd its content\n* And another headline\n\nWith some content"
+ ;; Show only headlines
+ (org-content)
+ ;; Set NEXT tag on current entry
+ (org-set-tags nil nil)
+ ;; Move point to that NEXT tag
+ (search-forward "NEXT") (backward-word)
+ ;; And it should be visible (i.e. no overlays)
+ (not (overlays-at (point))))))))
+
(ert-deftest test-org/show-set-visibility ()
"Test `org-show-set-visibility' specifications."
;; Do not throw an error before first heading.
--
2.10.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] Tag visibility fixup after setting them
2016-12-27 10:30 [PATCH] Tag visibility fixup after setting them Alexey Lebedeff
@ 2016-12-29 0:39 ` Nicolas Goaziou
2016-12-29 13:11 ` Alexey Lebedeff
0 siblings, 1 reply; 4+ messages in thread
From: Nicolas Goaziou @ 2016-12-29 0:39 UTC (permalink / raw)
To: Alexey Lebedeff; +Cc: Orgmode Mailing List
Hello,
Alexey Lebedeff <binarin@gmail.com> writes:
> This fixes bug where you sometimes can't immediately see tags that were
> just set. And to reveal them you need to go through global visibility
> cycle.
Thank you for the patch, and the test.
> +(defun org-insert-visible-text (&rest args)
> + "Inserts arguments at point and makes them visible in outline.
> +
> +When text is being inserted on the invisible region boundary, it
> +can be inadvertently sucked into invisibility."
> + (let* ((before-point (point)))
> + (apply #'insert args)
> + (outline-flag-region before-point (point) nil)))
I don't think, for the time being, it deserves a dedicated function.
I suggest to integrate it in `org-set-tags' instead.
Could you send an updated patch ?
Regards,
--
Nicolas Goaziou
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Tag visibility fixup after setting them
2016-12-29 0:39 ` Nicolas Goaziou
@ 2016-12-29 13:11 ` Alexey Lebedeff
2016-12-29 15:41 ` Nicolas Goaziou
0 siblings, 1 reply; 4+ messages in thread
From: Alexey Lebedeff @ 2016-12-29 13:11 UTC (permalink / raw)
To: Nicolas Goaziou; +Cc: Orgmode Mailing List
[-- Attachment #1.1: Type: text/plain, Size: 1098 bytes --]
Hi Nicolas,
I'm attaching updated patch. But I'm not sure it's a good idea to add
another 6 lines of code to the function which is already big enough.
Best,
Alexey
On Thu, Dec 29, 2016 at 3:39 AM, Nicolas Goaziou <mail@nicolasgoaziou.fr>
wrote:
> Hello,
>
> Alexey Lebedeff <binarin@gmail.com> writes:
>
> > This fixes bug where you sometimes can't immediately see tags that were
> > just set. And to reveal them you need to go through global visibility
> > cycle.
>
> Thank you for the patch, and the test.
>
> > +(defun org-insert-visible-text (&rest args)
> > + "Inserts arguments at point and makes them visible in outline.
> > +
> > +When text is being inserted on the invisible region boundary, it
> > +can be inadvertently sucked into invisibility."
> > + (let* ((before-point (point)))
> > + (apply #'insert args)
> > + (outline-flag-region before-point (point) nil)))
>
> I don't think, for the time being, it deserves a dedicated function.
> I suggest to integrate it in `org-set-tags' instead.
>
> Could you send an updated patch ?
>
>
> Regards,
>
> --
> Nicolas Goaziou
>
[-- Attachment #1.2: Type: text/html, Size: 1772 bytes --]
[-- Attachment #2: 0001-Reveal-tags-after-setting-them.patch --]
[-- Type: application/octet-stream, Size: 2408 bytes --]
From 7250ca8c3cbdc0e1b884cebce4bc16e260a3aa31 Mon Sep 17 00:00:00 2001
From: Alexey Lebedeff <binarin@gmail.com>
Date: Sun, 25 Dec 2016 13:24:04 +0300
Subject: [PATCH] Reveal tags after setting them
Sometimes freshly added tags can be sucked into invisible outline
region (denoted by ellipsis) - and to see them you need to do the full
global visibilty cycle.
---
lisp/org.el | 7 ++++++-
testing/lisp/test-org.el | 18 ++++++++++++++++++
2 files changed, 24 insertions(+), 1 deletion(-)
diff --git a/lisp/org.el b/lisp/org.el
index 3ddd80b..375c18d 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -15096,7 +15096,12 @@ When JUST-ALIGN is non-nil, only align tags."
;; white spaces.
(end-of-line)
(if (not (equal tags ""))
- (insert " " tags)
+ (let* ((before-point (point)))
+ (insert " " tags)
+ ;; When text is being inserted on an invisible
+ ;; region boundary, it can be inadvertently sucked
+ ;; into invisibility.
+ (outline-flag-region before-point (point) nil))
(skip-chars-backward " \t")
(delete-region (point) (line-end-position)))))
;; Align tags, if any. Fix tags column if `org-indent-mode'
diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el
index bbd0c0b..d60364a 100644
--- a/testing/lisp/test-org.el
+++ b/testing/lisp/test-org.el
@@ -5130,6 +5130,24 @@ Paragraph<point>"
(should-not
(org-test-with-temp-text "Paragraph" (org-hide-block-toggle-maybe))))
+(ert-deftest test-org/fast-tag-selection ()
+ "Test `org-fast-tag-selection'."
+ ;; Tags set via fast-tag-selection should be visible afterwards
+ (should
+ (let ((org-tag-alist '(("NEXT" . ?n)))
+ (org-fast-tag-selection-single-key t))
+ (cl-letf (((symbol-function 'read-char-exclusive) (lambda () ?n))
+ ((symbol-function 'window-width) (lambda (&rest args) 100)))
+ (org-test-with-temp-text "<point>* Headline\nAnd its content\n* And another headline\n\nWith some content"
+ ;; Show only headlines
+ (org-content)
+ ;; Set NEXT tag on current entry
+ (org-set-tags nil nil)
+ ;; Move point to that NEXT tag
+ (search-forward "NEXT") (backward-word)
+ ;; And it should be visible (i.e. no overlays)
+ (not (overlays-at (point))))))))
+
(ert-deftest test-org/show-set-visibility ()
"Test `org-show-set-visibility' specifications."
;; Do not throw an error before first heading.
--
2.10.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] Tag visibility fixup after setting them
2016-12-29 13:11 ` Alexey Lebedeff
@ 2016-12-29 15:41 ` Nicolas Goaziou
0 siblings, 0 replies; 4+ messages in thread
From: Nicolas Goaziou @ 2016-12-29 15:41 UTC (permalink / raw)
To: Alexey Lebedeff; +Cc: Orgmode Mailing List
Hello,
Alexey Lebedeff <binarin@gmail.com> writes:
> I'm attaching updated patch.
Applied. Thank you.
> But I'm not sure it's a good idea to add another 6 lines of code to
> the function which is already big enough.
The function is not massive either, and half the inserted lines are
comments anyway.
Besides, I tweaked the change so that it fits in a single loc (excluding
comments).
Regards,
--
Nicolas Goaziou
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-12-29 15:41 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-12-27 10:30 [PATCH] Tag visibility fixup after setting them Alexey Lebedeff
2016-12-29 0:39 ` Nicolas Goaziou
2016-12-29 13:11 ` Alexey Lebedeff
2016-12-29 15:41 ` Nicolas Goaziou
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.