emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Completely hide the :PROPERTIES: drawer in org-mode.
@ 2019-02-07 16:21 Keith David Bershatsky
  2019-02-12  8:37 ` Nicolas Goaziou
  0 siblings, 1 reply; 13+ messages in thread
From: Keith David Bershatsky @ 2019-02-07 16:21 UTC (permalink / raw)
  To: emacs-orgmode

A few years ago, I wrote up an answer to my own question on Stackoverflow to completely hide the :PROPERTIES: drawer, including the line that says :PROPERTIES:.  Since then, it has received nearly 5,000 views, 11 stars, 17 upvotes on the initial question, and 15 upvotes on the answer.

Today, a forum participant posted a comment underneath my answer asking why not send this upstream.  So, here is the link to the answer:

https://stackoverflow.com/a/17492723/2112489

Thanks,

Keith

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

* Re: Completely hide the :PROPERTIES: drawer in org-mode.
  2019-02-07 16:21 Completely hide the :PROPERTIES: drawer in org-mode Keith David Bershatsky
@ 2019-02-12  8:37 ` Nicolas Goaziou
  2019-02-12 20:17   ` Michaël Cadilhac
  0 siblings, 1 reply; 13+ messages in thread
From: Nicolas Goaziou @ 2019-02-12  8:37 UTC (permalink / raw)
  To: Keith David Bershatsky; +Cc: emacs-orgmode

Hello,

Keith David Bershatsky <esq@lawlist.com> writes:

> A few years ago, I wrote up an answer to my own question on
> Stackoverflow to completely hide the :PROPERTIES: drawer, including
> the line that says :PROPERTIES:. Since then, it has received nearly
> 5,000 views, 11 stars, 17 upvotes on the initial question, and 15
> upvotes on the answer.
>
> Today, a forum participant posted a comment underneath my answer asking why not send this upstream.  So, here is the link to the answer:
>
> https://stackoverflow.com/a/17492723/2112489

Thank you for the suggestion. 

However, I think hiding completely stuff from the user is not great. How
would you edit it, or even know there are properties there?

You can write ":properties:" instead of ":PROPERTIES:", dim them with an
appropriate face…

Regards,

-- 
Nicolas Goaziou

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

* Re: Completely hide the :PROPERTIES: drawer in org-mode.
  2019-02-12  8:37 ` Nicolas Goaziou
@ 2019-02-12 20:17   ` Michaël Cadilhac
  2019-02-13 14:32     ` Nicolas Goaziou
  0 siblings, 1 reply; 13+ messages in thread
From: Michaël Cadilhac @ 2019-02-12 20:17 UTC (permalink / raw)
  To: Keith David Bershatsky, emacs-orgmode

Hi there;

Agreed, hiding properties entirely seems overkill and quite limited in
use cases.  However, I think this stems from a more general need to
hide properties that are irrelevant to the user—for instance, UIDs
created by ox-icalendar, or other internal properties.  As a user, I
see no need whatsoever to see—let alone edit—such a property, and feel
that it clutters the display.  Assuming that properties are edited
using the suitable commands, no clash would be created by having a set
P of properties such that drawers with only P-properties would be
hidden.  What do you think?

Cheers;
M.

On Tue, 12 Feb 2019 at 08:38, Nicolas Goaziou <mail@nicolasgoaziou.fr> wrote:
>
> Hello,
>
> Keith David Bershatsky <esq@lawlist.com> writes:
>
> > A few years ago, I wrote up an answer to my own question on
> > Stackoverflow to completely hide the :PROPERTIES: drawer, including
> > the line that says :PROPERTIES:. Since then, it has received nearly
> > 5,000 views, 11 stars, 17 upvotes on the initial question, and 15
> > upvotes on the answer.
> >
> > Today, a forum participant posted a comment underneath my answer asking why not send this upstream.  So, here is the link to the answer:
> >
> > https://stackoverflow.com/a/17492723/2112489
>
> Thank you for the suggestion.
>
> However, I think hiding completely stuff from the user is not great. How
> would you edit it, or even know there are properties there?
>
> You can write ":properties:" instead of ":PROPERTIES:", dim them with an
> appropriate face…
>
> Regards,
>
> --
> Nicolas Goaziou
>

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

* Re: Completely hide the :PROPERTIES: drawer in org-mode.
  2019-02-12 20:17   ` Michaël Cadilhac
@ 2019-02-13 14:32     ` Nicolas Goaziou
  2019-02-13 15:11       ` Michaël Cadilhac
  2019-02-13 18:44       ` Marco Wahl
  0 siblings, 2 replies; 13+ messages in thread
From: Nicolas Goaziou @ 2019-02-13 14:32 UTC (permalink / raw)
  To: Michaël Cadilhac; +Cc: Keith David Bershatsky, emacs-orgmode

Hello,

Michaël Cadilhac <michael@cadilhac.name> writes:

> Agreed, hiding properties entirely seems overkill and quite limited in
> use cases.  However, I think this stems from a more general need to
> hide properties that are irrelevant to the user—for instance, UIDs
> created by ox-icalendar, or other internal properties.  As a user, I
> see no need whatsoever to see—let alone edit—such a property, and feel
> that it clutters the display.  Assuming that properties are edited
> using the suitable commands, no clash would be created by having a set
> P of properties such that drawers with only P-properties would be
> hidden.  What do you think?

Since properties drawers are almost exclusively folded, I don't think
incriminated properties clutter display. Besides, I don't think any
property is irrelevant to every user. How would we know?

More generally, I feel uneasy about completely hiding stuff. Org format
is not meant to be opaque. I think the current situation is fine, as far
as /core/ Org is concerned. Of course, users are free to extend it to
their own needs.

Regards,

-- 
Nicolas Goaziou

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

* Re: Completely hide the :PROPERTIES: drawer in org-mode.
  2019-02-13 14:32     ` Nicolas Goaziou
@ 2019-02-13 15:11       ` Michaël Cadilhac
  2019-02-13 15:55         ` Nicolas Goaziou
  2019-02-13 18:44       ` Marco Wahl
  1 sibling, 1 reply; 13+ messages in thread
From: Michaël Cadilhac @ 2019-02-13 15:11 UTC (permalink / raw)
  To: Michaël Cadilhac, Keith David Bershatsky, emacs-orgmode

On Wed, 13 Feb 2019 at 14:32, Nicolas Goaziou <mail@nicolasgoaziou.fr> wrote:

> Since properties drawers are almost exclusively folded, I don't think
> incriminated properties clutter display. Besides, I don't think any
> property is irrelevant to every user. How would we know?

I'd have a customizable list of unimportant/internal properties, and
if a property drawer only contains these properties, it is hidden.

You mention that these drawers don't clutter display, so as an
example, consider the following screenshot:
  https://michael.cadilhac.name/public/org-props.png
All the property drawers in that screenshot consist of "ID" elements
added by ox-icalendar.  Arguably, these properties are internal values
and their storage shouldn't interfere with the user's experience.

But I do understand being uneasy about hiding stuff.   Another
solution that would work for me would be to change the font size and
color a folded :PROPERTIES: drawer, and have a normal font when I open
the drawer.  Is there a way to do that?
I thought I could start playing with the face "org-drawer" but it
looks unused.  Any help?

Thanks!

Cheers;
M.

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

* Re: Completely hide the :PROPERTIES: drawer in org-mode.
  2019-02-13 15:11       ` Michaël Cadilhac
@ 2019-02-13 15:55         ` Nicolas Goaziou
  2019-02-14 14:16           ` Michaël Cadilhac
  0 siblings, 1 reply; 13+ messages in thread
From: Nicolas Goaziou @ 2019-02-13 15:55 UTC (permalink / raw)
  To: Michaël Cadilhac; +Cc: Keith David Bershatsky, emacs-orgmode

Michaël Cadilhac <michael@cadilhac.name> writes:

> You mention that these drawers don't clutter display, so as an
> example, consider the following screenshot:
>   https://michael.cadilhac.name/public/org-props.png

The face you use for drawers is, well obnoxious, to say the least. No
wonder you find them cluttering your display.

> All the property drawers in that screenshot consist of "ID" elements
> added by ox-icalendar.  Arguably, these properties are internal values
> and their storage shouldn't interfere with the user's experience.

These are not internal values only. You can use them as link targets,
too.

> But I do understand being uneasy about hiding stuff.   Another
> solution that would work for me would be to change the font size and
> color a folded :PROPERTIES: drawer, and have a normal font when I open
> the drawer.  Is there a way to do that?

I don't think that's possible out of the box, but font-lock stuff is
configurable.

> I thought I could start playing with the face "org-drawer" but it
> looks unused.  Any help?

It seems that, for some reason, drawers use `org-special-keyword'. It
sounds like a bug.

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

* Re: Completely hide the :PROPERTIES: drawer in org-mode.
  2019-02-13 14:32     ` Nicolas Goaziou
  2019-02-13 15:11       ` Michaël Cadilhac
@ 2019-02-13 18:44       ` Marco Wahl
  1 sibling, 0 replies; 13+ messages in thread
From: Marco Wahl @ 2019-02-13 18:44 UTC (permalink / raw)
  To: emacs-orgmode


> More generally, I feel uneasy about completely hiding stuff. Org format
> is not meant to be opaque. I think the current situation is fine, as far
> as /core/ Org is concerned. Of course, users are free to extend it to
> their own needs.

Yes, indeed.

Occasionally I use

#v+
#+begin_src elisp
; lexical binding, please!
(let (ols)

  (defun mw-org-hide-meta-heading-info ()
    "Hide meta data following headings."
    (interactive)
    (org-show-all) ; expand all props before make invisible to avoid ellipses.
    (save-excursion
      (goto-char (point-min))
      (unless (org-at-heading-p) (outline-next-heading))
      (while (not (eobp))
        (let ((beg (1+ (progn (end-of-line) (point))))
              (end (1- (progn (org-end-of-meta-data t) (point)))))
          (when (< beg end)
            (push (make-overlay beg end) ols)
            (overlay-put (car ols) 'invisible t)))
        (when (not (org-at-heading-p))
          (outline-next-heading)))))

  (defun mw-org-show-meta-info-lines ()
    "Show meta info."
    (interactive)
    (mapc #'delete-overlay ols)
    (setq ols nil)))
#+end_src
#v-

to completely get the property meta stuff out of sight.


Ciao,
-- 
Marco
GPG: http://pgp.mit.edu/pks/lookup?search=0x49010A040A3AE6F2

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

* Re: Completely hide the :PROPERTIES: drawer in org-mode.
  2019-02-13 15:55         ` Nicolas Goaziou
@ 2019-02-14 14:16           ` Michaël Cadilhac
  2019-02-14 16:11             ` Nicolas Goaziou
  0 siblings, 1 reply; 13+ messages in thread
From: Michaël Cadilhac @ 2019-02-14 14:16 UTC (permalink / raw)
  To: Michaël Cadilhac, Keith David Bershatsky, emacs-orgmode

Hi there;

Again, thanks for your help Nicolas—that's much appreciated.

On Wed, 13 Feb 2019 at 15:55, Nicolas Goaziou <mail@nicolasgoaziou.fr> wrote:
> The face you use for drawers is, well obnoxious, to say the least. No
> wonder you find them cluttering your display.

I agree; following your advice, I took the simpler path of customizing
org-special-keyword.  By changing its height, I got a small glitch;
consider:
  https://michael.cadilhac.name/public/org-props-small-1.png
The lines with ":PROPERTIES:" did not change height; this is simply
due to the line-feed having the default face.  With:

--- a/lisp/org.el
+++ b/lisp/org.el
@@ -5934,7 +5934,7 @@ by a #."
   "Fontify drawers."
   (when (re-search-forward org-drawer-regexp limit t)
     (add-text-properties
-     (match-beginning 0) (match-end 0)
+     (match-beginning 0) (+ 1 (match-end 0))
      '(font-lock-fontified t face org-special-keyword))
     (org-remove-flyspell-overlays-in (match-beginning 0) (match-end 0))
     t))

I get the desired outcome:
  https://michael.cadilhac.name/public/org-props-small-2.png

(this is also where org-special-keyword should be replaced with org-drawer.)

Any thoughts?

Thanks!

Michaël

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

* Re: Completely hide the :PROPERTIES: drawer in org-mode.
  2019-02-14 14:16           ` Michaël Cadilhac
@ 2019-02-14 16:11             ` Nicolas Goaziou
  2019-02-14 16:21               ` Michaël Cadilhac
  0 siblings, 1 reply; 13+ messages in thread
From: Nicolas Goaziou @ 2019-02-14 16:11 UTC (permalink / raw)
  To: Michaël Cadilhac; +Cc: Keith David Bershatsky, emacs-orgmode

Hello,

Michaël Cadilhac <michael@cadilhac.name> writes:

> I agree; following your advice, I took the simpler path of customizing
> org-special-keyword.  By changing its height, I got a small glitch;
> consider:
>   https://michael.cadilhac.name/public/org-props-small-1.png
> The lines with ":PROPERTIES:" did not change height; this is simply
> due to the line-feed having the default face.  With:
>
> --- a/lisp/org.el
> +++ b/lisp/org.el
> @@ -5934,7 +5934,7 @@ by a #."
>    "Fontify drawers."
>    (when (re-search-forward org-drawer-regexp limit t)
>      (add-text-properties
> -     (match-beginning 0) (match-end 0)
> +     (match-beginning 0) (+ 1 (match-end 0))

I suggest replacing (match-beginning 0) and (match-end 0) by,
respectively (line-beginning-position) and (line-beginning-position 2)

(+ 1 (match-end 0)) could be greater than (point-max),
(line-beginning-position 2) cannot.

>       '(font-lock-fontified t face org-special-keyword))
>      (org-remove-flyspell-overlays-in (match-beginning 0) (match-end 0))
>      t))
>
> I get the desired outcome:
>   https://michael.cadilhac.name/public/org-props-small-2.png
>
> (this is also where org-special-keyword should be replaced with org-drawer.)
>
> Any thoughts?

Would you want to provide a patch including the replacement of
`org-special-keyword' with `org-drawer'?

Thank you!

Regards,

-- 
Nicolas Goaziou

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

* Re: Completely hide the :PROPERTIES: drawer in org-mode.
  2019-02-14 16:11             ` Nicolas Goaziou
@ 2019-02-14 16:21               ` Michaël Cadilhac
  2019-02-14 23:15                 ` Nicolas Goaziou
  0 siblings, 1 reply; 13+ messages in thread
From: Michaël Cadilhac @ 2019-02-14 16:21 UTC (permalink / raw)
  To: Michaël Cadilhac, Keith David Bershatsky, emacs-orgmode

On Thu, 14 Feb 2019 at 16:11, Nicolas Goaziou <mail@nicolasgoaziou.fr> wrote:

> Would you want to provide a patch including the replacement of
> `org-special-keyword' with `org-drawer'?

Will do.  This in particular requires to swap fontifying the drawers
and the keywords (since :END: and :PROPERTIES: are keywords):

--- a/lisp/org.el
+++ b/lisp/org.el
@@ -6255,12 +6255,12 @@ needs to be inserted at a specific position in
the font-lock sequence.")
     '("^[ \t]*| *\\([#*]\\) *|" (1 'org-formula t))
     '("^[ \t]*|\\( *\\([$!_^/]\\) *|.*\\)|" (1 'org-formula t))
     '("| *\\(<[lrc]?[0-9]*>\\)" (1 'org-formula t))
-    ;; Drawers
-    '(org-fontify-drawers)
     ;; Properties
     (list org-property-re
  '(1 'org-special-keyword t)
  '(3 'org-property-value t))
+    ;; Drawers
+    '(org-fontify-drawers)
     ;; Link related fontification.
     '(org-activate-links)
     (when (memq 'tag lk) '(org-activate-tags (1 'org-tag prepend)))

Agreed?

Cheers;
M.

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

* Re: Completely hide the :PROPERTIES: drawer in org-mode.
  2019-02-14 16:21               ` Michaël Cadilhac
@ 2019-02-14 23:15                 ` Nicolas Goaziou
  2019-08-28 22:38                   ` Michaël Cadilhac
  0 siblings, 1 reply; 13+ messages in thread
From: Nicolas Goaziou @ 2019-02-14 23:15 UTC (permalink / raw)
  To: Michaël Cadilhac; +Cc: Keith David Bershatsky, emacs-orgmode

Michaël Cadilhac <michael@cadilhac.name> writes:

> Will do.  This in particular requires to swap fontifying the drawers
> and the keywords (since :END: and :PROPERTIES: are keywords):

[...]

> Agreed?

Sure. Please do what is necessary ;)

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

* Re: Completely hide the :PROPERTIES: drawer in org-mode.
  2019-02-14 23:15                 ` Nicolas Goaziou
@ 2019-08-28 22:38                   ` Michaël Cadilhac
  2019-09-05 16:54                     ` Nicolas Goaziou
  0 siblings, 1 reply; 13+ messages in thread
From: Michaël Cadilhac @ 2019-08-28 22:38 UTC (permalink / raw)
  To: emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 401 bytes --]

Apologies for the delay.

Is that alright?

On Thu, 14 Feb 2019 at 17:15, Nicolas Goaziou <mail@nicolasgoaziou.fr>
wrote:

> Michaël Cadilhac <michael@cadilhac.name> writes:
>
> > Will do.  This in particular requires to swap fontifying the drawers
> > and the keywords (since :END: and :PROPERTIES: are keywords):
>
> [...]
>
> > Agreed?
>
> Sure. Please do what is necessary ;)
>

[-- Attachment #1.2: Type: text/html, Size: 796 bytes --]

[-- Attachment #2: 0001-Fontify-drawers-correctly.patch --]
[-- Type: text/x-patch, Size: 1727 bytes --]

From aebea2663b929f0dbf8e1408c9ddb85f210e2c0c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C3=ABl=20Cadilhac?= <michael@cadilhac.name>
Date: Wed, 28 Aug 2019 16:26:06 -0500
Subject: [PATCH] Fontify drawers correctly.

* lisp/org.el (org-fontify-drawers): Fix face used, fix range of text
properties.
(org-set-font-lock-defaults): Fontify drawers after keywords.
---
 lisp/org.el | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index ea2c75130..31faac516 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -5356,9 +5356,10 @@ by a #."
   "Fontify drawers."
   (when (re-search-forward org-drawer-regexp limit t)
     (add-text-properties
-     (match-beginning 0) (match-end 0)
-     '(font-lock-fontified t face org-special-keyword))
-    (org-remove-flyspell-overlays-in (match-beginning 0) (match-end 0))
+     (line-beginning-position) (line-beginning-position 2)
+     '(font-lock-fontified t face org-drawer))
+    (org-remove-flyspell-overlays-in
+     (line-beginning-position) (line-beginning-position 2))
     t))
 
 (defun org-fontify-macros (limit)
@@ -5612,12 +5613,12 @@ needs to be inserted at a specific position in the font-lock sequence.")
 	   '("^[ \t]*| *\\([#*]\\) *|" (1 'org-formula t))
 	   '("^[ \t]*|\\( *\\([$!_^/]\\) *|.*\\)|" (1 'org-formula t))
 	   '("| *\\(<[lrc]?[0-9]*>\\)" (1 'org-formula t))
-	   ;; Drawers
-	   '(org-fontify-drawers)
 	   ;; Properties
 	   (list org-property-re
 		 '(1 'org-special-keyword t)
 		 '(3 'org-property-value t))
+	   ;; Drawers
+	   '(org-fontify-drawers)
 	   ;; Link related fontification.
 	   '(org-activate-links)
 	   (when (memq 'tag lk) '(org-activate-tags (1 'org-tag prepend)))
-- 
2.22.0


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

* Re: Completely hide the :PROPERTIES: drawer in org-mode.
  2019-08-28 22:38                   ` Michaël Cadilhac
@ 2019-09-05 16:54                     ` Nicolas Goaziou
  0 siblings, 0 replies; 13+ messages in thread
From: Nicolas Goaziou @ 2019-09-05 16:54 UTC (permalink / raw)
  To: Michaël Cadilhac; +Cc: emacs-orgmode

Hello,

Michaël Cadilhac <michael@cadilhac.name> writes:

> Apologies for the delay.
>
> Is that alright?

It is. Applied. Thank you!

Regards,

-- 
Nicolas Goaziou

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

end of thread, other threads:[~2019-09-05 16:54 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-02-07 16:21 Completely hide the :PROPERTIES: drawer in org-mode Keith David Bershatsky
2019-02-12  8:37 ` Nicolas Goaziou
2019-02-12 20:17   ` Michaël Cadilhac
2019-02-13 14:32     ` Nicolas Goaziou
2019-02-13 15:11       ` Michaël Cadilhac
2019-02-13 15:55         ` Nicolas Goaziou
2019-02-14 14:16           ` Michaël Cadilhac
2019-02-14 16:11             ` Nicolas Goaziou
2019-02-14 16:21               ` Michaël Cadilhac
2019-02-14 23:15                 ` Nicolas Goaziou
2019-08-28 22:38                   ` Michaël Cadilhac
2019-09-05 16:54                     ` Nicolas Goaziou
2019-02-13 18:44       ` Marco Wahl

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