Re: [O] Completely hide the :PROPERTIES: drawer in org-mode.

2019-09-05 Thread Nicolas Goaziou
Hello,

Michaël Cadilhac  writes:

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

It is. Applied. Thank you!

Regards,

-- 
Nicolas Goaziou



Re: [O] Completely hide the :PROPERTIES: drawer in org-mode.

2019-08-28 Thread Michaël Cadilhac
Apologies for the delay.

Is that alright?

On Thu, 14 Feb 2019 at 17:15, Nicolas Goaziou 
wrote:

> Michaël Cadilhac  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 ;)
>
From aebea2663b929f0dbf8e1408c9ddb85f210e2c0c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C3=ABl=20Cadilhac?= 
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



Re: [O] Completely hide the :PROPERTIES: drawer in org-mode.

2019-02-14 Thread Nicolas Goaziou
Michaël Cadilhac  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 ;)



Re: [O] Completely hide the :PROPERTIES: drawer in org-mode.

2019-02-14 Thread Michaël Cadilhac
On Thu, 14 Feb 2019 at 16:11, Nicolas Goaziou  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.



Re: [O] Completely hide the :PROPERTIES: drawer in org-mode.

2019-02-14 Thread Nicolas Goaziou
Hello,

Michaël Cadilhac  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



Re: [O] Completely hide the :PROPERTIES: drawer in org-mode.

2019-02-14 Thread Michaël Cadilhac
Hi there;

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

On Wed, 13 Feb 2019 at 15:55, Nicolas Goaziou  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



Re: [O] Completely hide the :PROPERTIES: drawer in org-mode.

2019-02-13 Thread Marco Wahl


> 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





Re: [O] Completely hide the :PROPERTIES: drawer in org-mode.

2019-02-13 Thread Nicolas Goaziou
Michaël Cadilhac  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.



Re: [O] Completely hide the :PROPERTIES: drawer in org-mode.

2019-02-13 Thread Michaël Cadilhac
On Wed, 13 Feb 2019 at 14:32, Nicolas Goaziou  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.



Re: [O] Completely hide the :PROPERTIES: drawer in org-mode.

2019-02-13 Thread Nicolas Goaziou
Hello,

Michaël Cadilhac  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



Re: [O] Completely hide the :PROPERTIES: drawer in org-mode.

2019-02-12 Thread Michaël Cadilhac
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  wrote:
>
> Hello,
>
> Keith David Bershatsky  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
>



Re: [O] Completely hide the :PROPERTIES: drawer in org-mode.

2019-02-12 Thread Nicolas Goaziou
Hello,

Keith David Bershatsky  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



[O] Completely hide the :PROPERTIES: drawer in org-mode.

2019-02-07 Thread Keith David Bershatsky
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