unofficial mirror of emacs-orgmode@gnu.org
 help / color / Atom feed
* [PATCH] Add mode for automatically unhiding emphasis markers in the current region
@ 2020-06-01 14:14 Shankar Rao
  2020-06-01 15:33 ` Shankar Rao
  0 siblings, 1 reply; 12+ messages in thread
From: Shankar Rao @ 2020-06-01 14:14 UTC (permalink / raw)
  To: emacs-orgmode

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

* lisp/org.el:
(org-auto-emphasis-unhide-at-point): Parameter that controls the
behavior of Org Auto Emphasis mode.  It can be one of the values nil, t, and
'right-edge, and works similarly to the parameter
`prettify-symbols-unprettify-at-point' for `prettify-symbols-mode'.
(org-do-emphasis-faces): When hiding emphasis markers, add additional
text properties 'org-emph-start and org-emph-end to the emphasized
region.
(org-auto-emphasis--current-region-bounds): Local variable containing
the bounds of the region whose emphasis markers are currently
unhidden.
(org-auto-emphasis--get-prop-as-list): Helper function that returns
Org Auto Emphasis properties as a list.
(org-auto-emphasis--post-command-hook): Function added to
`post-command-hook' that rehides emphasis markers for the previous
region and unhides emphasis marks for the current region.
(org-auto-emphasis-mode): Toggles Org Auto Emphasis mode.  Can be
added to `org-mode-hook' to be enabled for all org-mode files.

This code was adapted from prettify-symbols-mode in prog-mode.el

I have not yet signed the papers assigning copyright to the FSF.  I sent a
request for the papers to assign@gnu.org, but have not yet received a
response.

Shankar Rao

---
 lisp/org.el | 98 +++++++++++++++++++++++++++++++++++++++++++++++------
 1 file changed, 87 insertions(+), 11 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index 7ff7ec685..870c5c958 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -3644,6 +3644,19 @@ following symbols:
   :type 'boolean
   :safe #'booleanp)

+(defcustom org-auto-emphasis-unhide-at-point nil
+  "If non-nil, unhide the emphasis markers for the region when point is on
it.
+If set to the symbol `right-edge', also unhide the emphasis
+markers if point is immediately after the emphasized region.  The
+emphasis markers will be rehidden as soon as point moves away
+from the region.  If set to nil, the emphasis markers remain
+hidden even when point is in the region."
+  :version "25.1"
+  :type '(choice (const :tag "Never unhide emphasis markers" nil)
+                 (const :tag "Unhide emphasis markers when point is
inside" t)
+                 (const :tag "Unhide emphasis markers when point is inside
or at right edge" right-edge))
+  :group 'org-appearance)
+
 (defcustom org-hide-macro-markers nil
   "Non-nil mean font-lock should hide the brackets marking macro calls."
   :group 'org-appearance
@@ -5056,12 +5069,77 @@ stacked delimiters is N.  Escaping delimiters is
not possible."
    '(font-lock-multiline t org-emphasis t))
       (when (and org-hide-emphasis-markers
  (not (org-at-comment-p)))
- (add-text-properties (match-end 4) (match-beginning 5)
-     '(invisible org-link))
- (add-text-properties (match-beginning 3) (match-end 3)
-     '(invisible org-link)))
+ (let ((s1 (match-beginning 3))
+      (e1 (match-end 3))
+      (s2 (match-end 4))
+      (e2 (match-beginning 5)))
+  (add-text-properties s2 e2 '(invisible org-link))
+  (add-text-properties s1 e1 '(invisible org-link))
+  (add-text-properties s1 e2
+       `(org-emph-start ,s1 org-emph-end ,e2))))
       (throw :exit t))))))))

+(defvar-local org-auto-emphasis--current-region-bounds nil)
+
+(defun org-auto-emphasis--get-prop-as-list (prop)
+  "Helper function to get org-auto-emphasis properties as a list.
+If `org-auto-emphasis-unhide-at-point' is set to `t' then return
+the text property PROP at point in a list. If
+`org-auto-emphasis-unhide-at-point' is set to `right-edge', the
+also include the text property PROP at point-1 unless we are at
+the beginning of the buffer."
+  (remove nil
+  (list (get-text-property (point) prop)
+ (when (and (eq org-auto-emphasis-unhide-at-point 'right-edge)
+   (not (bobp)))
+  (get-text-property (1- (point)) prop)))))
+
+(defun org-auto-emphasis--post-command-hook ()
+  ;; Rehide emphasis markers for the previous region.
+  (when (and org-auto-emphasis--current-region-bounds
+     (or (< (point) (car org-auto-emphasis--current-region-bounds))
+ (> (point) (cadr org-auto-emphasis--current-region-bounds))
+ (and (not (eq org-auto-emphasis-unhide-at-point 'right-edge))
+      (= (point) (cadr org-auto-emphasis--current-region-bounds)))))
+ (apply #'font-lock-flush org-auto-emphasis--current-region-bounds)
+ (setq org-auto-emphasis--current-region-bounds nil))
+  ;; Unhide emphasis markers for the current region.
+  (when-let* ((s (org-auto-emphasis--get-prop-as-list 'org-emph-start))
+      (e (org-auto-emphasis--get-prop-as-list 'org-emph-end))
+      (s (apply #'min s))
+      (e (apply #'max e)))
+    (with-silent-modifications
+      (setq org-auto-emphasis--current-region-bounds (list s e))
+      (remove-text-properties s (1+ s) '(invisible org-link))
+      (remove-text-properties (1- e) e '(invisible org-link)))))
+
+(define-minor-mode org-auto-emphasis-mode
+  "Toggle Org Auto Emphasis mode.
+This mode, when enabled, unhides emphasis markers for the region
+at point, depending on the value of
+`org-auto-emphasis-unhide-at-point'. With a prefix argument ARG,
+enable Org Auto Emphasis mode if ARG is positive, and disable it
+otherwise.  If called from Lisp, enable the mode if ARG is
+omitted or nil.
+
+To enable this in all org-mode files, add the following line to init.el:
+
+  (add-hook 'org-mode #'org-auto-emphasis-mode)
+"
+  :init-value nil
+  (if org-auto-emphasis-mode
+      ;; Turn on
+      (progn
+        (setq-local font-lock-extra-managed-props
+                    (append font-lock-extra-managed-props
+                            '(org-emph-start org-emph-end)))
+        (when org-auto-emphasis-unhide-at-point
+          (add-hook 'post-command-hook
+                    #'org-auto-emphasis--post-command-hook nil t))
+        (font-lock-flush))
+    ;; Turn off
+    (remove-hook 'post-command-hook #'org-auto-emphasis--post-command-hook
t)))
+
 (defun org-emphasize (&optional char)
   "Insert or change an emphasis, i.e. a font like bold or italic.
 If there is an active region, change that region to a new emphasis.
@@ -20482,16 +20560,15 @@ With ARG, repeats or can move backward if
negative."
    (beginning-of-line))
   (_ nil)))
       (cl-incf arg))
-    (while (and (> arg 0) (re-search-forward regexp nil t))
+    (while (and (> arg 0) (re-search-forward regexp nil :move))
       (pcase (get-char-property-and-overlay (point) 'invisible)
  (`(outline . ,o)
  (goto-char (overlay-end o))
- (skip-chars-forward " \t\n")
- (end-of-line))
+ (end-of-line 2))
  (_
  (end-of-line)))
       (cl-decf arg))
-    (if (> arg 0) (goto-char (point-max)) (beginning-of-line))))
+    (when (/= arg initial-arg) (beginning-of-line))))

 (defun org-previous-visible-heading (arg)
   "Move to the previous visible heading.
@@ -20830,11 +20907,10 @@ ones already marked."
  (set-mark
  (save-excursion
    (goto-char (mark))
-   (goto-char (org-element-property :end (org-element-at-point)))
-   (point)))
+   (goto-char (org-element-property :end (org-element-at-point)))))
       (let ((element (org-element-at-point)))
  (end-of-line)
- (push-mark (min (point-max) (org-element-property :end element)) t t)
+ (push-mark (org-element-property :end element) t t)
  (goto-char (org-element-property :begin element))))))

 (defun org-narrow-to-element ()
-- 
2.17.1

[-- Attachment #2: Type: text/html, Size: 8382 bytes --]

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

* Re: [PATCH] Add mode for automatically unhiding emphasis markers in the current region
  2020-06-01 14:14 [PATCH] Add mode for automatically unhiding emphasis markers in the current region Shankar Rao
@ 2020-06-01 15:33 ` Shankar Rao
  2020-06-22  5:40   ` Kyle Meyer
  0 siblings, 1 reply; 12+ messages in thread
From: Shankar Rao @ 2020-06-01 15:33 UTC (permalink / raw)
  To: emacs-orgmode


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

Sorry, I've never submitted a patch before. Looking through this mailing
list, I see that you're supposed to attach the .patch file to the e-mail,
so here it is.

This patch adds a minor mode that makes emphasis markers be automatically
unhidden when the point is inside the region of emphasis and then the
markers are rehidden when the point is moved elsewhere. I posted this on
/r/orgmode on reddit (
https://www.reddit.com/r/orgmode/comments/gss1g4/update_i_made_my_own_sbrorgemphasizemode_that/),
and people there suggested that I submit this here as a patch.

Shankar

On Mon, Jun 1, 2020 at 4:14 PM Shankar Rao <shankar.rao@gmail.com> wrote:

> * lisp/org.el:
> (org-auto-emphasis-unhide-at-point): Parameter that controls the
> behavior of Org Auto Emphasis mode.  It can be one of the values nil, t,
> and
> 'right-edge, and works similarly to the parameter
> `prettify-symbols-unprettify-at-point' for `prettify-symbols-mode'.
> (org-do-emphasis-faces): When hiding emphasis markers, add additional
> text properties 'org-emph-start and org-emph-end to the emphasized
> region.
> (org-auto-emphasis--current-region-bounds): Local variable containing
> the bounds of the region whose emphasis markers are currently
> unhidden.
> (org-auto-emphasis--get-prop-as-list): Helper function that returns
> Org Auto Emphasis properties as a list.
> (org-auto-emphasis--post-command-hook): Function added to
> `post-command-hook' that rehides emphasis markers for the previous
> region and unhides emphasis marks for the current region.
> (org-auto-emphasis-mode): Toggles Org Auto Emphasis mode.  Can be
> added to `org-mode-hook' to be enabled for all org-mode files.
>
> This code was adapted from prettify-symbols-mode in prog-mode.el
>
> I have not yet signed the papers assigning copyright to the FSF.  I sent a
> request for the papers to assign@gnu.org, but have not yet received a
> response.
>
> Shankar Rao
>
> ---
>  lisp/org.el | 98 +++++++++++++++++++++++++++++++++++++++++++++++------
>  1 file changed, 87 insertions(+), 11 deletions(-)
>
> diff --git a/lisp/org.el b/lisp/org.el
> index 7ff7ec685..870c5c958 100644
> --- a/lisp/org.el
> +++ b/lisp/org.el
> @@ -3644,6 +3644,19 @@ following symbols:
>    :type 'boolean
>    :safe #'booleanp)
>
> +(defcustom org-auto-emphasis-unhide-at-point nil
> +  "If non-nil, unhide the emphasis markers for the region when point is
> on it.
> +If set to the symbol `right-edge', also unhide the emphasis
> +markers if point is immediately after the emphasized region.  The
> +emphasis markers will be rehidden as soon as point moves away
> +from the region.  If set to nil, the emphasis markers remain
> +hidden even when point is in the region."
> +  :version "25.1"
> +  :type '(choice (const :tag "Never unhide emphasis markers" nil)
> +                 (const :tag "Unhide emphasis markers when point is
> inside" t)
> +                 (const :tag "Unhide emphasis markers when point is
> inside or at right edge" right-edge))
> +  :group 'org-appearance)
> +
>  (defcustom org-hide-macro-markers nil
>    "Non-nil mean font-lock should hide the brackets marking macro calls."
>    :group 'org-appearance
> @@ -5056,12 +5069,77 @@ stacked delimiters is N.  Escaping delimiters is
> not possible."
>     '(font-lock-multiline t org-emphasis t))
>        (when (and org-hide-emphasis-markers
>   (not (org-at-comment-p)))
> - (add-text-properties (match-end 4) (match-beginning 5)
> -     '(invisible org-link))
> - (add-text-properties (match-beginning 3) (match-end 3)
> -     '(invisible org-link)))
> + (let ((s1 (match-beginning 3))
> +      (e1 (match-end 3))
> +      (s2 (match-end 4))
> +      (e2 (match-beginning 5)))
> +  (add-text-properties s2 e2 '(invisible org-link))
> +  (add-text-properties s1 e1 '(invisible org-link))
> +  (add-text-properties s1 e2
> +       `(org-emph-start ,s1 org-emph-end ,e2))))
>        (throw :exit t))))))))
>
> +(defvar-local org-auto-emphasis--current-region-bounds nil)
> +
> +(defun org-auto-emphasis--get-prop-as-list (prop)
> +  "Helper function to get org-auto-emphasis properties as a list.
> +If `org-auto-emphasis-unhide-at-point' is set to `t' then return
> +the text property PROP at point in a list. If
> +`org-auto-emphasis-unhide-at-point' is set to `right-edge', the
> +also include the text property PROP at point-1 unless we are at
> +the beginning of the buffer."
> +  (remove nil
> +  (list (get-text-property (point) prop)
> + (when (and (eq org-auto-emphasis-unhide-at-point 'right-edge)
> +   (not (bobp)))
> +  (get-text-property (1- (point)) prop)))))
> +
> +(defun org-auto-emphasis--post-command-hook ()
> +  ;; Rehide emphasis markers for the previous region.
> +  (when (and org-auto-emphasis--current-region-bounds
> +     (or (< (point) (car org-auto-emphasis--current-region-bounds))
> + (> (point) (cadr org-auto-emphasis--current-region-bounds))
> + (and (not (eq org-auto-emphasis-unhide-at-point 'right-edge))
> +      (= (point) (cadr org-auto-emphasis--current-region-bounds)))))
> + (apply #'font-lock-flush org-auto-emphasis--current-region-bounds)
> + (setq org-auto-emphasis--current-region-bounds nil))
> +  ;; Unhide emphasis markers for the current region.
> +  (when-let* ((s (org-auto-emphasis--get-prop-as-list 'org-emph-start))
> +      (e (org-auto-emphasis--get-prop-as-list 'org-emph-end))
> +      (s (apply #'min s))
> +      (e (apply #'max e)))
> +    (with-silent-modifications
> +      (setq org-auto-emphasis--current-region-bounds (list s e))
> +      (remove-text-properties s (1+ s) '(invisible org-link))
> +      (remove-text-properties (1- e) e '(invisible org-link)))))
> +
> +(define-minor-mode org-auto-emphasis-mode
> +  "Toggle Org Auto Emphasis mode.
> +This mode, when enabled, unhides emphasis markers for the region
> +at point, depending on the value of
> +`org-auto-emphasis-unhide-at-point'. With a prefix argument ARG,
> +enable Org Auto Emphasis mode if ARG is positive, and disable it
> +otherwise.  If called from Lisp, enable the mode if ARG is
> +omitted or nil.
> +
> +To enable this in all org-mode files, add the following line to init.el:
> +
> +  (add-hook 'org-mode #'org-auto-emphasis-mode)
> +"
> +  :init-value nil
> +  (if org-auto-emphasis-mode
> +      ;; Turn on
> +      (progn
> +        (setq-local font-lock-extra-managed-props
> +                    (append font-lock-extra-managed-props
> +                            '(org-emph-start org-emph-end)))
> +        (when org-auto-emphasis-unhide-at-point
> +          (add-hook 'post-command-hook
> +                    #'org-auto-emphasis--post-command-hook nil t))
> +        (font-lock-flush))
> +    ;; Turn off
> +    (remove-hook 'post-command-hook
> #'org-auto-emphasis--post-command-hook t)))
> +
>  (defun org-emphasize (&optional char)
>    "Insert or change an emphasis, i.e. a font like bold or italic.
>  If there is an active region, change that region to a new emphasis.
> @@ -20482,16 +20560,15 @@ With ARG, repeats or can move backward if
> negative."
>     (beginning-of-line))
>    (_ nil)))
>        (cl-incf arg))
> -    (while (and (> arg 0) (re-search-forward regexp nil t))
> +    (while (and (> arg 0) (re-search-forward regexp nil :move))
>        (pcase (get-char-property-and-overlay (point) 'invisible)
>   (`(outline . ,o)
>   (goto-char (overlay-end o))
> - (skip-chars-forward " \t\n")
> - (end-of-line))
> + (end-of-line 2))
>   (_
>   (end-of-line)))
>        (cl-decf arg))
> -    (if (> arg 0) (goto-char (point-max)) (beginning-of-line))))
> +    (when (/= arg initial-arg) (beginning-of-line))))
>
>  (defun org-previous-visible-heading (arg)
>    "Move to the previous visible heading.
> @@ -20830,11 +20907,10 @@ ones already marked."
>   (set-mark
>   (save-excursion
>     (goto-char (mark))
> -   (goto-char (org-element-property :end (org-element-at-point)))
> -   (point)))
> +   (goto-char (org-element-property :end (org-element-at-point)))))
>        (let ((element (org-element-at-point)))
>   (end-of-line)
> - (push-mark (min (point-max) (org-element-property :end element)) t t)
> + (push-mark (org-element-property :end element) t t)
>   (goto-char (org-element-property :begin element))))))
>
>  (defun org-narrow-to-element ()
> --
> 2.17.1
>

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

[-- Attachment #2: 0001-Add-mode-for-automatically-unhiding-emphasis-markers.patch --]
[-- Type: application/octet-stream, Size: 7404 bytes --]

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

* Re: [PATCH] Add mode for automatically unhiding emphasis markers in the current region
  2020-06-01 15:33 ` Shankar Rao
@ 2020-06-22  5:40   ` Kyle Meyer
  2020-06-22 11:25     ` Gustavo Barros
  0 siblings, 1 reply; 12+ messages in thread
From: Kyle Meyer @ 2020-06-22  5:40 UTC (permalink / raw)
  To: Shankar Rao; +Cc: emacs-orgmode

Thanks for the patch, and sorry for the slow reply.

Shankar Rao writes:

> Sorry, I've never submitted a patch before. Looking through this mailing
> list, I see that you're supposed to attach the .patch file to the e-mail,
> so here it is.

Inline is fine as well, though it can take a little more work on the
sender's end to make sure that the patch doesn't get mangled by their
mail client and that the commit message is formatted correctly.

> This patch adds a minor mode that makes emphasis markers be automatically
> unhidden when the point is inside the region of emphasis and then the
> markers are rehidden when the point is moved elsewhere. I posted this on
> /r/orgmode on reddit (
> https://www.reddit.com/r/orgmode/comments/gss1g4/update_i_made_my_own_sbrorgemphasizemode_that/),
> and people there suggested that I submit this here as a patch.

I don't prefer my emphasis markers hidden (i.e. I leave
org-hide-emphasis-markers at nil), so perhaps I'm not the best to judge,
but that does sound like a nice feature.

I'm hoping others will try this out and give their thoughts.

> On Mon, Jun 1, 2020 at 4:14 PM Shankar Rao <shankar.rao@gmail.com> wrote:
[...]
>>
>> This code was adapted from prettify-symbols-mode in prog-mode.el
>>
>> I have not yet signed the papers assigning copyright to the FSF.  I sent a
>> request for the papers to assign@gnu.org, but have not yet received a
>> response.

Are you still waiting for a response?

> Subject: [PATCH] Add mode for automatically unhiding emphasis markers in the
>  current region
[...]
>  lisp/org.el | 98 +++++++++++++++++++++++++++++++++++++++++++++++------
>  1 file changed, 87 insertions(+), 11 deletions(-)
>
> diff --git a/lisp/org.el b/lisp/org.el
> index 7ff7ec685..870c5c958 100644

Note that this no longer applies to the current master due to a conflict
with b68090e0b (2020-06-04).  I applied this to b68090e0b^ to try this
out, and it seems to work as advertised.

Here are some comments from an initial read-through.

> --- a/lisp/org.el
> +++ b/lisp/org.el
> @@ -3644,6 +3644,19 @@ following symbols:
>    :type 'boolean
>    :safe #'booleanp)
>  
> +(defcustom org-auto-emphasis-unhide-at-point nil
> +  "If non-nil, show the unhide the emphasis markers for the region when point is on it.

s/show the// ?

Also, I find using "region" here (and elsewhere) a little confusing.
Perhaps something like "unhide the emphasis markers for the text at
point" instead?

> +If set to the symbol `right-edge', also unhide the emphasis
> +markers if point is immediately after the emphasized region.  The
> +emphasis markers will be rehidden as soon as point moves away
> +from the region.  If set to nil, the emphasis markers remain
> +hidden even when point is in the region."
> +  :version "25.1"

This can instead be

    :package-version '(Org . "9.5")

Emacs can then use customize-package-emacs-version-alist to map to the
Emacs version.

(The next release will be v9.4, but we're in a feature freeze at the
moment.)

> +  :type '(choice (const :tag "Never unhide emphasis markers" nil)

Hmm, I don't see the point of having a nil value.  That already seems
covered by toggling org-auto-emphasis-mode on and off.

I also wonder whether we can get away with not having an option here at
all.  Is one of the below values more likely to be the predominant
preference?

> +                 (const :tag "Unhide emphasis markers when point is inside" t)
> +                 (const :tag "Unhide emphasis markers when point is inside or at right edge" right-edge))

IMO these descriptions could be more concise but as clear by dropping
"emphasis markers" from the t and right-edge items.

> +(defvar-local org-auto-emphasis--current-region-bounds nil)
> +
> +(defun org-auto-emphasis--get-prop-as-list (prop)
> +  "Helper function to get org-auto-emphasis properties as a list.
> +If `org-auto-emphasis-unhide-at-point' is set to `t' then return

convention nit: Drop quotes from t.

> +(defun org-auto-emphasis--post-command-hook ()
> +  ;; Rehide emphasis markers for the previous region.
> +  (when (and org-auto-emphasis--current-region-bounds
> +	     (or (< (point) (car org-auto-emphasis--current-region-bounds))
> +		 (> (point) (cadr org-auto-emphasis--current-region-bounds))
> +		 (and (not (eq org-auto-emphasis-unhide-at-point 'right-edge))
> +		      (= (point) (cadr org-auto-emphasis--current-region-bounds)))))
> +	(apply #'font-lock-flush org-auto-emphasis--current-region-bounds)
> +	(setq org-auto-emphasis--current-region-bounds nil))
> +  ;; Unhide emphasis markers for the current region.
> +  (when-let* ((s (org-auto-emphasis--get-prop-as-list 'org-emph-start))

Our minimum supported Emacs version is 24.3, so we can't rely on
when-let and friends being available.

> +(define-minor-mode org-auto-emphasis-mode
> +  "Toggle Org Auto Emphasis mode.
> +This mode, when enabled, unhides emphasis markers for the region
> +at point, depending on the value of
> +`org-auto-emphasis-unhide-at-point'. With a prefix argument ARG,
> +enable Org Auto Emphasis mode if ARG is positive, and disable it
> +otherwise.  If called from Lisp, enable the mode if ARG is
> +omitted or nil.
> +
> +To enable this in all org-mode files, add the following line to init.el:

nit: s/org-mode/Org/

> +
> +  (add-hook 'org-mode #'org-auto-emphasis-mode)

You should protect the apostrophes as \\=' so that they aren't rendered
according to text-quoting-style.

>  (defun org-emphasize (&optional char)
>    "Insert or change an emphasis, i.e. a font like bold or italic.
>  If there is an active region, change that region to a new emphasis.
> @@ -20482,16 +20560,15 @@ With ARG, repeats or can move backward if negative."
>  	   (beginning-of-line))
>  	  (_ nil)))
>        (cl-incf arg))
> -    (while (and (> arg 0) (re-search-forward regexp nil t))
> +    (while (and (> arg 0) (re-search-forward regexp nil :move))
>        (pcase (get-char-property-and-overlay (point) 'invisible)
>  	(`(outline . ,o)
>  	 (goto-char (overlay-end o))
> -	 (skip-chars-forward " \t\n")
> -	 (end-of-line))
> +	 (end-of-line 2))
>  	(_
>  	 (end-of-line)))
>        (cl-decf arg))
> -    (if (> arg 0) (goto-char (point-max)) (beginning-of-line))))
> +    (when (/= arg initial-arg) (beginning-of-line))))

Can you explain why this change to org-next-visible-heading and...

>  
>  (defun org-previous-visible-heading (arg)
>    "Move to the previous visible heading.
> @@ -20830,11 +20907,10 @@ ones already marked."
>  	(set-mark
>  	 (save-excursion
>  	   (goto-char (mark))
> -	   (goto-char (org-element-property :end (org-element-at-point)))
> -	   (point)))
> +	   (goto-char (org-element-property :end (org-element-at-point)))))
>        (let ((element (org-element-at-point)))
>  	(end-of-line)
> -	(push-mark (min (point-max) (org-element-property :end element)) t t)
> +	(push-mark (org-element-property :end element) t t)
>  	(goto-char (org-element-property :begin element))))))

... this change to org-mark-element are related/needed?


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

* Re: [PATCH] Add mode for automatically unhiding emphasis markers in the current region
  2020-06-22  5:40   ` Kyle Meyer
@ 2020-06-22 11:25     ` Gustavo Barros
  2020-06-23  0:07       ` Kyle Meyer
  0 siblings, 1 reply; 12+ messages in thread
From: Gustavo Barros @ 2020-06-22 11:25 UTC (permalink / raw)
  To: Kyle Meyer; +Cc: emacs-orgmode, Shankar Rao


Hi Kyle, Hi Shankar,

On Mon, 22 Jun 2020 at 05:40, Kyle Meyer <kyle@kyleam.com> wrote:

> Shankar Rao writes:
>
>> This patch adds a minor mode that makes emphasis markers be automatically
>> unhidden when the point is inside the region of emphasis and then the
>> markers are rehidden when the point is moved elsewhere. I posted this on
>> /r/orgmode on reddit (
>> https://www.reddit.com/r/orgmode/comments/gss1g4/update_i_made_my_own_sbrorgemphasizemode_that/),
>> and people there suggested that I submit this here as a patch.
>
> I don't prefer my emphasis markers hidden (i.e. I leave
> org-hide-emphasis-markers at nil), so perhaps I'm not the best to judge,
> but that does sound like a nice feature.
>
> I'm hoping others will try this out and give their thoughts.

Just an user here, but I'd like to leave my +1 to this proposed feature.
I did use org-hide-emphasis-markers in the past and I liked it, but
eventually dropped it because of the inconveniences of editing at the
border of an emphasized region.  This proposed feature eliminates the
"which side of the invisible character are we?" ambiguity, so I repute
it very nice indeed.  I would certainly appreciate the inclusion of such
a feature and, since I've been around, I've seen folks demanding
something of the sort (memory here, no hard data).  Indeed, I was one of
the people at Reddit who suggested Shankar submitted this to the list.

I did (lightly) test the code as posted on Reddit, and liked what I
saw.  I tried a number of cases I could think of: multiple lines, nested
emphasis markers etc.  As far as I tried, it did work as advertised.

I also did report a corner case I found:

> The only edge case I found, which in no way mars the absolute coolness
> of this, is when you are actually inserting the emphasis marker. For
> example, if you type *word*. Right after you type the last "*" the
> emphasis will be hidden, even though the point position would have it to
> be shown. Same thing if you select word and "C-c C-x C-f *". You have to
> actually move point, for the mode to work in this situation.

Shankar replied me this behavior is the same in prettify-symbols-mode,
on which the code is based.  I do not use prettify-symbols-mode myself,
but did play with it a little because of this, and could not infer a
regularity, so I must trust Shankar's point here.  And it is indeed just
a corner situation, which has no further implication I can conceive, and
which does not diminish the usefulness of the feature.

I can add another thought on the matter.  While prettify-symbols is a
mode, org-hide-emphasis-markers is an option/variable.  So I wonder if
the feature would fit better the current state of things in Org as
either another option/defcustom or by simply expanding the range of
possible values for org-hide-emphasis-markers (e.g. t, nil,
not-at-point, not-at-point-right-edge).  But this is just a thought, I'd
be happy to see this feature be included either way.

So, thanks Shankar for proposing the patch, and thanks Kyle for
reviewing it.

HTH.
Best,
Gustavo.


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

* Re: [PATCH] Add mode for automatically unhiding emphasis markers in the current region
  2020-06-22 11:25     ` Gustavo Barros
@ 2020-06-23  0:07       ` Kyle Meyer
  2020-06-24 12:53         ` Shankar Rao
  0 siblings, 1 reply; 12+ messages in thread
From: Kyle Meyer @ 2020-06-23  0:07 UTC (permalink / raw)
  To: Gustavo Barros; +Cc: emacs-orgmode, Shankar Rao

Gustavo Barros writes:

> Just an user here, but I'd like to leave my +1 to this proposed feature.
> [...]

Thanks.  That's very useful feedback.

> I can add another thought on the matter.  While prettify-symbols is a
> mode, org-hide-emphasis-markers is an option/variable.  So I wonder if
> the feature would fit better the current state of things in Org as
> either another option/defcustom or by simply expanding the range of
> possible values for org-hide-emphasis-markers (e.g. t, nil,
> not-at-point, not-at-point-right-edge).  But this is just a thought, I'd
> be happy to see this feature be included either way.

Hmm, yeah, that's worth thinking about.  I mentioned eliminating the
org-auto-emphasis-unhide-at-point option, but I didn't consider doing it
by absorbing the values into org-hide-emphasis-markers and dropping the
mode.  Given what org-auto-emphasis-mode does underneath, though, it
does fit quite neatly into a minor mode toggle.


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

* Re: [PATCH] Add mode for automatically unhiding emphasis markers in the current region
  2020-06-23  0:07       ` Kyle Meyer
@ 2020-06-24 12:53         ` Shankar Rao
  2020-06-24 13:49           ` Gustavo Barros
  0 siblings, 1 reply; 12+ messages in thread
From: Shankar Rao @ 2020-06-24 12:53 UTC (permalink / raw)
  To: Kyle Meyer; +Cc: emacs-orgmode, Gustavo Barros


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

Kyle, Gustavo,

Thank you both for your detailed feedback. Attached is a new version of the
patch that incorporates most of your suggestions.

>> I have not yet signed the papers assigning copyright to the FSF.  I sent
> a
> >> request for the papers to assign@gnu.org, but have not yet received a
> >> response.
>
> Are you still waiting for a response?
>
I received an assignment form from the FSF and I just now signed it and
sent it back to them.

> +  :type '(choice (const :tag "Never unhide emphasis markers" nil)
>
> Hmm, I don't see the point of having a nil value.  That already seems
> covered by toggling org-auto-emphasis-mode on and off.
>
> I also wonder whether we can get away with not having an option here at
> all.  Is one of the below values more likely to be the predominant
> preference?
>
This mimics the behavior of prettify-symbols-mode.
org-auto-emphasis-unhide-at-point and org-auto-emphasis-mode correspond to
prettify-symbols-unprettify-at-point and global-prettify-symbols-mode,
respectively. So in the same way, one could enable prettify-symbols-mode
globally with (global-prettify-symbols-mode +1) and also have (setq
prettify-symbols-unprettify-at-point nil), which would effectively still
keep it disabled.

I'm amenable to simplifying or eliminating the option entirely. In my use I
find the 'right-edge setting to be more useful that the t setting, but the
behavior for t might be more intuitive to users. If I had to pick one
option, I would choose 'right-edge.

> I can add another thought on the matter.  While prettify-symbols is a
> > mode, org-hide-emphasis-markers is an option/variable.  So I wonder if
> > the feature would fit better the current state of things in Org as
> > either another option/defcustom or by simply expanding the range of
> > possible values for org-hide-emphasis-markers (e.g. t, nil,
> > not-at-point, not-at-point-right-edge).  But this is just a thought, I'd
> > be happy to see this feature be included either way.
>
> Hmm, yeah, that's worth thinking about.  I mentioned eliminating the
> org-auto-emphasis-unhide-at-point option, but I didn't consider doing it
> by absorbing the values into org-hide-emphasis-markers and dropping the
> mode.  Given what org-auto-emphasis-mode does underneath, though, it
> does fit quite neatly into a minor mode toggle.
>
I agree that adding this functionality as additional options to
org-hide-emphasis-markers would be more intuitive and elegant for users, as
they wouldn't have to perform  (add-hook 'org-mode
#'org-auto-emphasis-mode) in order to enable this mode. I didn't implement
it this way first because I wanted to make the simplest, least disruptive
way possible, and secondly because I didn't quite know how to implement it
:-). As you can see in the patch, besides the additional functions and
variables, my code only modifies one preexisting org function, replacing
four lines with my new eight lines.

To implement this functionality in the way Gustavo suggests, we would have
to for all users add org-auto-emphasis--post-command-hook to
post-command-hook, and modify it so that it only operates when
org-hide-emphasis-markers is 'not-at-point or 'not-at-point-right-edge. I
can try to implement this if you think it would be a good idea, but I have
one concern. Even if a user is not interested in org-auto-emphasis-mode,
this implementation would add a small amount of code to post-command-hook,
so would have the effect of slightly slowing down their system.

Shankar

On Tue, Jun 23, 2020 at 2:07 AM Kyle Meyer <kyle@kyleam.com> wrote:

> Gustavo Barros writes:
>
> > Just an user here, but I'd like to leave my +1 to this proposed feature.
> > [...]
>
> Thanks.  That's very useful feedback.
>
> > I can add another thought on the matter.  While prettify-symbols is a
> > mode, org-hide-emphasis-markers is an option/variable.  So I wonder if
> > the feature would fit better the current state of things in Org as
> > either another option/defcustom or by simply expanding the range of
> > possible values for org-hide-emphasis-markers (e.g. t, nil,
> > not-at-point, not-at-point-right-edge).  But this is just a thought, I'd
> > be happy to see this feature be included either way.
>
> Hmm, yeah, that's worth thinking about.  I mentioned eliminating the
> org-auto-emphasis-unhide-at-point option, but I didn't consider doing it
> by absorbing the values into org-hide-emphasis-markers and dropping the
> mode.  Given what org-auto-emphasis-mode does underneath, though, it
> does fit quite neatly into a minor mode toggle.
>

---
 lisp/org.el | 87 ++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 83 insertions(+), 4 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index 4d46b4173..8bab33ec0 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -3644,6 +3644,19 @@ following symbols:
   :type 'boolean
   :safe #'booleanp)

+(defcustom org-auto-emphasis-unhide-at-point nil
+  "If non-nil, unhide the emphasis markers for the text at point.
+If set to the symbol `right-edge', also unhide the emphasis
+markers if point is immediately after the emphasized text.  The
+emphasis markers will be rehidden as soon as point moves away
+from the emphasized text.  If set to nil, the emphasis markers
+always remain hidden."
+  :package-version '(Org . "9.5")
+  :type '(choice (const :tag "Never unhide emphasis markers" nil)
+                 (const :tag "Unhide when point is inside" t)
+                 (const :tag "Unhide when point is inside or at right
edge" right-edge))
+  :group 'org-appearance)
+
 (defcustom org-hide-macro-markers nil
   "Non-nil mean font-lock should hide the brackets marking macro calls."
   :group 'org-appearance
@@ -5055,12 +5068,78 @@ stacked delimiters is N.  Escaping delimiters is
not possible."
    '(font-lock-multiline t org-emphasis t))
       (when (and org-hide-emphasis-markers
  (not (org-at-comment-p)))
- (add-text-properties (match-end 4) (match-beginning 5)
-     '(invisible org-link))
- (add-text-properties (match-beginning 3) (match-end 3)
-     '(invisible org-link)))
+ (let ((s1 (match-beginning 3))
+      (e1 (match-end 3))
+      (s2 (match-end 4))
+      (e2 (match-beginning 5)))
+  (add-text-properties s2 e2 '(invisible org-link))
+  (add-text-properties s1 e1 '(invisible org-link))
+  (add-text-properties s1 e2
+       `(org-emph-start ,s1 org-emph-end ,e2))))
       (throw :exit t))))))))

+(defvar-local org-auto-emphasis--current-region-bounds nil)
+
+(defun org-auto-emphasis--get-prop-as-list (prop)
+  "Helper function to get org-auto-emphasis properties as a list.
+If `org-auto-emphasis-unhide-at-point' is set to t, then return
+the text property PROP at point in a list. If
+`org-auto-emphasis-unhide-at-point' is set to `right-edge', the
+also include the text property PROP at point-1 unless we are at
+the beginning of the buffer."
+  (remove nil
+  (list (get-text-property (point) prop)
+ (when (and (eq org-auto-emphasis-unhide-at-point 'right-edge)
+   (not (bobp)))
+  (get-text-property (1- (point)) prop)))))
+
+(defun org-auto-emphasis--post-command-hook ()
+  ;; Rehide emphasis markers for the previous region.
+  (when (and org-auto-emphasis--current-region-bounds
+     (or (< (point) (car org-auto-emphasis--current-region-bounds))
+ (> (point) (cadr org-auto-emphasis--current-region-bounds))
+ (and (not (eq org-auto-emphasis-unhide-at-point 'right-edge))
+      (= (point) (cadr org-auto-emphasis--current-region-bounds)))))
+ (apply #'font-lock-flush org-auto-emphasis--current-region-bounds)
+ (setq org-auto-emphasis--current-region-bounds nil))
+  ;; Unhide emphasis markers for the current region.
+  (let* ((s (org-auto-emphasis--get-prop-as-list 'org-emph-start))
+ (e (and s (org-auto-emphasis--get-prop-as-list 'org-emph-end)))
+ (s (and e (apply #'min s)))
+ (e (and s (apply #'max e))))
+    (when e
+      (with-silent-modifications
+ (setq org-auto-emphasis--current-region-bounds (list s e))
+ (remove-text-properties s (1+ s) '(invisible org-link))
+ (remove-text-properties (1- e) e '(invisible org-link))))))
+
+(define-minor-mode org-auto-emphasis-mode
+  "Toggle Org Auto Emphasis mode.
+This mode, when enabled, unhides emphasis markers for the text
+at point, depending on the value of
+`org-auto-emphasis-unhide-at-point'. With a prefix argument ARG,
+enable Org Auto Emphasis mode if ARG is positive, and disable it
+otherwise.  If called from Lisp, enable the mode if ARG is
+omitted or nil.
+
+To enable this in all Org files, add the following line to init.el:
+
+  (add-hook \\='org-mode #\\='org-auto-emphasis-mode)
+"
+  :init-value nil
+  (if org-auto-emphasis-mode
+      ;; Turn on
+      (progn
+        (setq-local font-lock-extra-managed-props
+                    (append font-lock-extra-managed-props
+                            '(org-emph-start org-emph-end)))
+        (when org-auto-emphasis-unhide-at-point
+          (add-hook 'post-command-hook
+                    #'org-auto-emphasis--post-command-hook nil t))
+        (font-lock-flush))
+    ;; Turn off
+    (remove-hook 'post-command-hook #'org-auto-emphasis--post-command-hook
t)))
+
 (defun org-emphasize (&optional char)
   "Insert or change an emphasis, i.e. a font like bold or italic.
 If there is an active region, change that region to a new emphasis.
-- 
2.17.1

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

[-- Attachment #2: 0001-Add-mode-for-automatically-unhiding-emphasis-markers.patch --]
[-- Type: application/x-patch, Size: 6102 bytes --]

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

* Re: [PATCH] Add mode for automatically unhiding emphasis markers in the current region
  2020-06-24 12:53         ` Shankar Rao
@ 2020-06-24 13:49           ` Gustavo Barros
  2020-06-24 15:46             ` Nicolas Goaziou
  0 siblings, 1 reply; 12+ messages in thread
From: Gustavo Barros @ 2020-06-24 13:49 UTC (permalink / raw)
  To: Shankar Rao; +Cc: emacs-orgmode

Hi Shankar,

Detailed comments are up for Kyle, or someone more qualified than 
myself, but I leave one further comment regarding the suggestion I had 
made.

On Wed, 24 Jun 2020 at 09:53, Shankar Rao <shankar.rao@gmail.com> wrote:

> I agree that adding this functionality as additional options to
> org-hide-emphasis-markers would be more intuitive and elegant for 
> users, as
> they wouldn't have to perform  (add-hook 'org-mode
> #'org-auto-emphasis-mode) in order to enable this mode. I didn't 
> implement
> it this way first because I wanted to make the simplest, least 
> disruptive
> way possible, and secondly because I didn't quite know how to 
> implement it
> :-). As you can see in the patch, besides the additional functions and
> variables, my code only modifies one preexisting org function, 
> replacing
> four lines with my new eight lines.
>
> To implement this functionality in the way Gustavo suggests, we would 
> have
> to for all users add org-auto-emphasis--post-command-hook to
> post-command-hook, and modify it so that it only operates when
> org-hide-emphasis-markers is 'not-at-point or 
> 'not-at-point-right-edge. I
> can try to implement this if you think it would be a good idea, but I 
> have
> one concern. Even if a user is not interested in 
> org-auto-emphasis-mode,
> this implementation would add a small amount of code to 
> post-command-hook,
> so would have the effect of slightly slowing down their system.

You have a good point here.  When I made the suggestion I was naively 
thinking the featured could be plugged/hooked somewhere in Org, when 
fontification is done.  But that's not really true, as the feature 
requires being run every time the point moves too.  So, as far as I can 
tell, it seems using post-command-hook is unavoidable, and if so, you 
are right in not wanting to add some load to it for everyone, regardless 
of whether they want this feature or not.  You and Kyle have me 
convinced here.

And thanks again!

Best,
Gustavo.


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

* Re: [PATCH] Add mode for automatically unhiding emphasis markers in the current region
  2020-06-24 13:49           ` Gustavo Barros
@ 2020-06-24 15:46             ` Nicolas Goaziou
  2020-06-24 16:34               ` Shankar Rao
  2020-06-24 17:27               ` Gustavo Barros
  0 siblings, 2 replies; 12+ messages in thread
From: Nicolas Goaziou @ 2020-06-24 15:46 UTC (permalink / raw)
  To: Gustavo Barros; +Cc: emacs-orgmode, Shankar Rao

Hello,

Gustavo Barros <gusbrs.2016@gmail.com> writes:

> You have a good point here.  When I made the suggestion I was naively
> thinking the featured could be plugged/hooked somewhere in Org, when
> fontification is done.  But that's not really true, as the feature
> requires being run every time the point moves too.  So, as far as
> I can tell, it seems using post-command-hook is unavoidable, and if
> so, you are right in not wanting to add some load to it for everyone,
> regardless of whether they want this feature or not.  You and Kyle
> have me convinced here.

Sorry for being late to the party, but, IMO, this doesn't sound like
a right approach to the problem of invisible emphasis markers. A user
choosing to hide emphasis markers should not need to—or even be given
the opportunity to—display them in order to edit them efficiently.

I think we should upgrade `org-emphasize' command instead, so it handles
both marker visibility states in a DWIM, or in a word processor,
fashion. Indeed, since emphasis markers of a given type cannot be nested
in Org, the WIM part is usually easy to guess, according to the context,
i.e., the syntax at point, and the region. I have some draft lying
somewhere in that direction.

WDYT?

Regards,
-- 
Nicolas Goaziou


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

* Re: [PATCH] Add mode for automatically unhiding emphasis markers in the current region
  2020-06-24 15:46             ` Nicolas Goaziou
@ 2020-06-24 16:34               ` Shankar Rao
  2020-06-26  7:32                 ` Nicolas Goaziou
  2020-06-24 17:27               ` Gustavo Barros
  1 sibling, 1 reply; 12+ messages in thread
From: Shankar Rao @ 2020-06-24 16:34 UTC (permalink / raw)
  To: Gustavo Barros, Shankar Rao, emacs-orgmode

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

> Sorry for being late to the party, but, IMO, this doesn't sound like
> a right approach to the problem of invisible emphasis markers. A user
> choosing to hide emphasis markers should not need to—or even be given
> the opportunity to—display them in order to edit them efficiently.
>

I agree that if org-emphasize handled marker visibility states in a DWIM
fashion, then a user should not need to display them, but why do you
believe they shouldn't have the opportunity, especially given that this is
the exact behavior of prettify-symbols-mode?

Could you walk me through, in your proposed DWIM system, how a user should
be able to remove or change emphasis markers after they are rendered and
hidden?

Shankar

[-- Attachment #2: Type: text/html, Size: 1005 bytes --]

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

* Re: [PATCH] Add mode for automatically unhiding emphasis markers in the current region
  2020-06-24 15:46             ` Nicolas Goaziou
  2020-06-24 16:34               ` Shankar Rao
@ 2020-06-24 17:27               ` Gustavo Barros
  1 sibling, 0 replies; 12+ messages in thread
From: Gustavo Barros @ 2020-06-24 17:27 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: emacs-orgmode, Shankar Rao

Hi Nicolas,

On Wed, 24 Jun 2020 at 12:46, Nicolas Goaziou <mail@nicolasgoaziou.fr> 
wrote:

> Hello,
>
> Gustavo Barros <gusbrs.2016@gmail.com> writes:
>
>> You have a good point here.  When I made the suggestion I was naively
>> thinking the featured could be plugged/hooked somewhere in Org, when
>> fontification is done.  But that's not really true, as the feature
>> requires being run every time the point moves too.  So, as far as
>> I can tell, it seems using post-command-hook is unavoidable, and if
>> so, you are right in not wanting to add some load to it for everyone,
>> regardless of whether they want this feature or not.  You and Kyle
>> have me convinced here.
>
> Sorry for being late to the party, but, IMO, this doesn't sound like
> a right approach to the problem of invisible emphasis markers. A user
> choosing to hide emphasis markers should not need to—or even be given
> the opportunity to—display them in order to edit them efficiently.
>

I do agree with what you said, as you have stated it: It'd be good if 
the user of `org-hide-emphasis-markers' didn't need to display the 
invisible character to edit them efficiently.  And it is true that I 
argued in favor of this proposed patch giving the related editing 
inconveniences as a main point.  But the feature is the equivalent of 
`prettify-symbols-unprettify-at-point' for `org-hide-emphasis-markers' 
and it does have an appeal in itself, for the visual cue it offers, 
besides the editing improvement, which is a byproduct.  I like 
`org-hide-emphasis-markers', but if I was not "given the opportunity to 
display them" or if I could not edit them directly even if invisible, as 
a word processor does, I would probably not consider ever hiding them in 
the first place.

> I think we should upgrade `org-emphasize' command instead, so it 
> handles
> both marker visibility states in a DWIM, or in a word processor,
> fashion. Indeed, since emphasis markers of a given type cannot be 
> nested
> in Org, the WIM part is usually easy to guess, according to the 
> context,
> i.e., the syntax at point, and the region. I have some draft lying
> somewhere in that direction.
>
> WDYT?

I think that it would be great independently of the proposed patch. 
Indeed, that would be very useful including for users which set 
`org-hide-emphasis-markers' to nil.  On the other hand, even with a more 
capable dwim `org-empasize', I'm pretty sure many users will still add 
emphasis markers by directly typing them, even if occasionally, or they 
will delete them inadvertently if invisible, in which case, the proposed 
patch remains very useful for this reason too.

If I may, `TeX-font' in AUCTeX would be my dream `org-emphasize'.  Two 
things it does that `org-emphasize' doesn't (as far as I know of): i) 
when there is no region selected, and point is within a font macro, it 
operates on the imediate enclosing font macro, not requiring region 
selection, so that we can change the font macro by calling `TeX-font' 
with a prefix, or remove the font macro with "C-c C-f C-d"; ii) 
`LaTeX-font-list' is customizable, allowing for better key bindings; 
it's easier to type "b" than "*", "s" than "+" etc., anyway, it gives 
choice.

Again, just an user here, just offering a data point.  (And I was quoted 
;-).

Best,
Gustavo.


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

* Re: [PATCH] Add mode for automatically unhiding emphasis markers in the current region
  2020-06-24 16:34               ` Shankar Rao
@ 2020-06-26  7:32                 ` Nicolas Goaziou
  2020-07-03 15:19                   ` Shankar Rao
  0 siblings, 1 reply; 12+ messages in thread
From: Nicolas Goaziou @ 2020-06-26  7:32 UTC (permalink / raw)
  To: Shankar Rao; +Cc: emacs-orgmode, Gustavo Barros

Hello,

Shankar Rao <shankar.rao@gmail.com> writes:

> I agree that if org-emphasize handled marker visibility states in a DWIM
> fashion, then a user should not need to display them, but why do you
> believe they shouldn't have the opportunity, especially given that this is
> the exact behavior of prettify-symbols-mode?

I wrote my message in a hurry. Let me clarify it.

I'm only talking about built-in tooling. I don't mind if a user have the
feature you're proposing, of course, as it is not wrong per se.

However, I believe that's not the best solution for the problem we're
trying to solve. I think there's an opportunity to provide something
smarter, and less intrusive, to handle emphasis, which doesn't involve
messing with `post-command-hook'.

> Could you walk me through, in your proposed DWIM system, how a user should
> be able to remove or change emphasis markers after they are rendered and
> hidden?

Like in a word processor, you don't need to see the markers to operate
on them. I don't think the usual "toggle" model is appropriate, however.
I suggest to use two commands: one for deleting the markers around point
or within active region, and one for inserting markers or extending
existing ones.

Allow me to polish up my draft a bit, so we can compare the benefits of
each system.

Regards,
-- 
Nicolas Goaziou


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

* Re: [PATCH] Add mode for automatically unhiding emphasis markers in the current region
  2020-06-26  7:32                 ` Nicolas Goaziou
@ 2020-07-03 15:19                   ` Shankar Rao
  0 siblings, 0 replies; 12+ messages in thread
From: Shankar Rao @ 2020-07-03 15:19 UTC (permalink / raw)
  To: Shankar Rao, Gustavo Barros, emacs-orgmode

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

Hi,

I wrote my message in a hurry. Let me clarify it.
>
> I'm only talking about built-in tooling. I don't mind if a user have the
> feature you're proposing, of course, as it is not wrong per se.
>
> However, I believe that's not the best solution for the problem we're
> trying to solve. I think there's an opportunity to provide something
> smarter, and less intrusive, to handle emphasis, which doesn't involve
> messing with `post-command-hook'.
>

I agree with you that my solution is somewhat intrusive. Ideally, I would
have preferred that my solution could leverage advice functions or some Org
hook, so that I wouldn't have to modify org.el, but it doesn't seem like
there is a straightforward way to do that. The modification of
`post-command-hook', similar to one used for `prettify-symbols-mode', only
occurs if `org-auto-emphasis-mode' is active


> Like in a word processor, you don't need to see the markers to operate
> on them. I don't think the usual "toggle" model is appropriate, however.
> I suggest to use two commands: one for deleting the markers around point
> or within active region, and one for inserting markers or extending
> existing ones.
>
So in your system, in order to interact with emphasis markers, the user
would have to learn two different commands? That doesn't seem to be in line
with the dwim philosophy used in modern emacs packages.

In my opinion, one of the strengths of Org is that the interface is
multimodal. One can (in principle) edit documents in much the same way as
word processors and rich text editors. However since everything underneath
is implemented with just text, one can also directly access and manipulate
this text. The ability to switch between these two modalities is extremely
powerful and is what sets Org apart from other document editing systems.


> Allow me to polish up my draft a bit, so we can compare the benefits of
> each system.
>

I look forward to seeing your proposed system more concretely.

Shankar Rao

[-- Attachment #2: Type: text/html, Size: 2739 bytes --]

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

end of thread, back to index

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-01 14:14 [PATCH] Add mode for automatically unhiding emphasis markers in the current region Shankar Rao
2020-06-01 15:33 ` Shankar Rao
2020-06-22  5:40   ` Kyle Meyer
2020-06-22 11:25     ` Gustavo Barros
2020-06-23  0:07       ` Kyle Meyer
2020-06-24 12:53         ` Shankar Rao
2020-06-24 13:49           ` Gustavo Barros
2020-06-24 15:46             ` Nicolas Goaziou
2020-06-24 16:34               ` Shankar Rao
2020-06-26  7:32                 ` Nicolas Goaziou
2020-07-03 15:19                   ` Shankar Rao
2020-06-24 17:27               ` Gustavo Barros

unofficial mirror of emacs-orgmode@gnu.org

Archives are clonable:
	git clone --mirror https://yhetil.org/orgmode/0 orgmode/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 orgmode orgmode/ https://yhetil.org/orgmode \
		emacs-orgmode@gnu.org
	public-inbox-index orgmode

Example config snippet for mirrors

Newsgroups are available over NNTP:
	nntp://news.yhetil.org/yhetil.emacs.orgmode
	nntp://news.gmane.io/gmane.emacs.orgmode


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git