From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id riikJexM815/WQAA0tVLHw (envelope-from ) for ; Wed, 24 Jun 2020 12:54:04 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id QHoQIexM8175fgAAbx9fmQ (envelope-from ) for ; Wed, 24 Jun 2020 12:54:04 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id B0B7B9404C3 for ; Wed, 24 Jun 2020 12:54:03 +0000 (UTC) Received: from localhost ([::1]:55610 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jo4ue-0003vv-Sf for larch@yhetil.org; Wed, 24 Jun 2020 08:54:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35410) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jo4uA-0003u7-9s for emacs-orgmode@gnu.org; Wed, 24 Jun 2020 08:53:30 -0400 Received: from mail-vk1-xa42.google.com ([2607:f8b0:4864:20::a42]:43399) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jo4u7-0006Pw-IS for emacs-orgmode@gnu.org; Wed, 24 Jun 2020 08:53:30 -0400 Received: by mail-vk1-xa42.google.com with SMTP id q69so482919vkq.10 for ; Wed, 24 Jun 2020 05:53:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=RMaofdnhLdW2FhdDbzdj1OqfWgI3SA/FAH1Cvz3LO4I=; b=Vqx8Y+ZZGZKbgeTEgx3Qz5GaJ4z5D6dXRxQ4kAqYV+j1lQ9icSSH3uRryH0WInkN2y +2CnlbQpuHNgF0USOiSFkFlmGeG6D2JRGWHYGv2G0ahyfF4pfF56dWvkNoLSMuXsVS9l 4eDSY5tP42vkjCAdJIhThmhH3h4i2nkbBFNnt1pHTMAy6zPsLKJ8U0PODIzbCud00/2A exjNYuDAJCWJEbljuidkbYo5pikCrJtBP7poqDIv2WC2kvTMuXuDqHMg2z1paZ5WPvdX Y3OmHFVFMs0Tn79fh6UjrPdr9fGpLE7422z8nTezNUatZU0uf9mm+HiN1xA26Wz72UuR 6mxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=RMaofdnhLdW2FhdDbzdj1OqfWgI3SA/FAH1Cvz3LO4I=; b=MQ/OPeTYaKjFh5+c43V5QhtQFBj0sMt27ulGt1Hg1uuI7jHDO7KjWGquP/Lg7ksK/D VE/01OmnO6Pjo3LAQb1YbiXTdrYI5ESguxWyo45q2Fy0uFegB2hZw1pDdzrx2MFl028b Wzb5cal3drpQUdM7aODqqg7aDRMWObxV/nsVBqKIqN42Vhg9xzolNx3imdBfSP/ziQdE 5V8gXRdhMsBIeSnEEsd+5lwQ+5YMxZgMdHlwdkAXx3S4ErQIDSHMN9uRB06h7k1vzG+D lthJ3u3yhh1aZoUdv8OVKjzQZCaoRVCGNlq+EYmyJXyMnybAprVAljr1124pwWLCVKUz lA9g== X-Gm-Message-State: AOAM5315MT/4mNSrSkDxh1NEtL4dp6M+lM0DcRsdebymw32A9i8LMx9H pFSjoDksr/M1k21NH+zGAslHEVdPA9g3gO7hwON0v9pv X-Google-Smtp-Source: ABdhPJzOjC+OhKgp+QHPAnkpdeRDskJvIFYE9+Ojw+KPLv0sbdeuP4S+hS5OU4JrrYXNPoi+modnykDVot0LdCdtI4Q= X-Received: by 2002:a1f:930f:: with SMTP id v15mr22252176vkd.63.1593003206330; Wed, 24 Jun 2020 05:53:26 -0700 (PDT) MIME-Version: 1.0 References: <877dvzwtdy.fsf@kyleam.com> <87d05rcpgh.fsf@gmail.com> <871rm6wson.fsf@kyleam.com> In-Reply-To: <871rm6wson.fsf@kyleam.com> From: Shankar Rao Date: Wed, 24 Jun 2020 14:53:14 +0200 Message-ID: Subject: Re: [PATCH] Add mode for automatically unhiding emphasis markers in the current region To: Kyle Meyer Content-Type: multipart/mixed; boundary="0000000000003d7a1405a8d3f6dc" Received-SPF: pass client-ip=2607:f8b0:4864:20::a42; envelope-from=shankar.rao@gmail.com; helo=mail-vk1-xa42.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: emacs-orgmode@gnu.org, Gustavo Barros Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=fail (body hash did not verify) header.d=gmail.com header.s=20161025 header.b=Vqx8Y+ZZ; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Spam-Score: 0.09 X-TUID: EDNX29Ya6Koh --0000000000003d7a1405a8d3f6dc Content-Type: multipart/alternative; boundary="0000000000003d7a1105a8d3f6da" --0000000000003d7a1105a8d3f6da Content-Type: text/plain; charset="UTF-8" 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 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 --0000000000003d7a1105a8d3f6da Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Kyle, Gustavo,

Thank you bot= h for your detailed feedback. Attached is a new version of the patch that i= ncorporates most of your suggestions.

>> I have not yet signed the papers assigning copyright to the = FSF.=C2=A0 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 receive= d an assignment form from the FSF and I just now signed it and sent it back= to them.

> +=C2=A0 :type '(choice (const :tag "Never unhide emphas= is markers" nil)

Hmm, I don't see the point of having a nil value.=C2=A0 That already se= ems
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.=C2=A0 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, resp= ectively. So in the same way, one could enable prettify-symbols-mode global= ly with (global-prettify-symbols-mode +1) and also have (setq prettify-symb= ols-unprettify-at-point nil), which would effectively still keep it disable= d.

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

> I can add another thought on the matter.=C2= =A0 While prettify-symbols is a
> mode, org-hide-emphasis-markers is an option/variable.=C2=A0 So I wond= er 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).=C2=A0 But this is just a thoug= ht, I'd
> be happy to see this feature be included either way.

Hmm, yeah, that's worth thinking about.=C2=A0 I mentioned eliminating t= he
org-auto-emphasis-unhide-at-point option, but I didn't consider doing i= t
by absorbing the values into org-hide-emphasis-markers and dropping the
mode.=C2=A0 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 additiona= l options to org-hide-emphasis-markers would be more intuitive and elegant = for users, as they wouldn't have to perform=C2=A0 (add-hook 'org-mo= de #'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 d= isruptive way possible, and secondly because I didn't quite know how to= implement it :-). As you can see in the patch, besides the additional func= tions and variables, my code only modifies one preexisting org function, re= placing four lines with my new eight lines.

To imp= lement 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, a= nd modify it so that it only operates when org-hide-emphasis-markers is = 9;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 us= er is not interested in org-auto-emphasis-mode, this implementation would a= dd 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:
<= blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-l= eft:1px solid rgb(204,204,204);padding-left:1ex">Gustavo Barros writes:

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

Thanks.=C2=A0 That's very useful feedback.

> I can add another thought on the matter.=C2=A0 While prettify-symbols = is a
> mode, org-hide-emphasis-markers is an option/variable.=C2=A0 So I wond= er 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).=C2=A0 But this is just a thoug= ht, I'd
> be happy to see this feature be included either way.

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

---
=C2=A0lisp/org.el | 87 ++++++++++++++++++++++++++++++++++++= ++++++++++++++---
=C2=A01 file changed, 83 insertions(+), 4 deletions(-)=

diff --git a/lisp/org.el b/lisp/org.el
index 4d46b4173..8bab33ec= 0 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -3644,6 +3644,19 @= @ following symbols:
=C2=A0 =C2=A0:type 'boolean
=C2=A0 =C2=A0:sa= fe #'booleanp)
=C2=A0
+(defcustom org-auto-emphasis-unhide-at-poi= nt nil
+ =C2=A0"If non-nil, unhide the emphasis markers for the tex= t at point.
+If set to the symbol `right-edge', also unhide the emph= asis
+markers if point is immediately after the emphasized text.=C2=A0 T= he
+emphasis markers will be rehidden as soon as point moves away
+fr= om the emphasized text.=C2=A0 If set to nil, the emphasis markers
+alway= s remain hidden."
+ =C2=A0:package-version '(Org . "9.5&qu= ot;)
+ =C2=A0:type '(choice (const :tag "Never unhide emphasis = markers" nil)
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 (const :tag "Unhide when point is inside" t)
+ =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (const :tag "Unhide w= hen point is inside or at right edge" right-edge))
+ =C2=A0:group &= #39;org-appearance)
+
=C2=A0(defcustom org-hide-macro-markers nil
= =C2=A0 =C2=A0"Non-nil mean font-lock should hide the brackets marking = macro calls."
=C2=A0 =C2=A0:group 'org-appearance
@@ -5055,1= 2 +5068,78 @@ stacked delimiters is N.=C2=A0 Escaping delimiters is not pos= sible."
=C2=A0 =C2=A0 '(font-lock-multiline t org-emphasis = t))
=C2=A0 =C2=A0 =C2=A0 =C2=A0(when (and org-hide-emphasis-markers
= =C2=A0 (not (org-at-comment-p)))
- (add-text-properties (match-end 4= ) (match-beginning 5)
- =C2=A0 =C2=A0 '(invisible org-link))
= - (add-text-properties (match-beginning 3) (match-end 3)
- =C2=A0 = =C2=A0 '(invisible org-link)))
+ (let ((s1 (match-beginning 3))
= + =C2=A0 =C2=A0 =C2=A0(e1 (match-end 3))
+ =C2=A0 =C2=A0 =C2=A0(s2 (= match-end 4))
+ =C2=A0 =C2=A0 =C2=A0(e2 (match-beginning 5)))
+ = =C2=A0(add-text-properties s2 e2 '(invisible org-link))
+ =C2=A0(a= dd-text-properties s1 e1 '(invisible org-link))
+ =C2=A0(add-text-= properties s1 e2
+ =C2=A0 =C2=A0 =C2=A0 `(org-emph-start ,s1 org-emp= h-end ,e2))))
=C2=A0 =C2=A0 =C2=A0 =C2=A0(throw :exit t))))))))
=C2= =A0
+(defvar-local org-auto-emphasis--current-region-bounds nil)
++(defun org-auto-emphasis--get-prop-as-list (prop)
+ =C2=A0"Helper= function to get org-auto-emphasis properties as a list.
+If `org-auto-e= mphasis-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 po= int-1 unless we are at
+the beginning of the buffer."
+ =C2=A0(r= emove nil
+ =C2=A0(list (get-text-property (point) prop)
+ (when (a= nd (eq org-auto-emphasis-unhide-at-point 'right-edge)
+ =C2=A0 (n= ot (bobp)))
+ =C2=A0(get-text-property (1- (point)) prop)))))
+
= +(defun org-auto-emphasis--post-command-hook ()
+ =C2=A0;; Rehide emphas= is markers for the previous region.
+ =C2=A0(when (and org-auto-emphasis= --current-region-bounds
+ =C2=A0 =C2=A0 (or (< (point) (car org-auto= -emphasis--current-region-bounds))
+ (> (point) (cadr org-auto-emph= asis--current-region-bounds))
+ (and (not (eq org-auto-emphasis-unhide= -at-point 'right-edge))
+ =C2=A0 =C2=A0 =C2=A0(=3D (point) (cadr o= rg-auto-emphasis--current-region-bounds)))))
+ (apply #'font-lock-fl= ush org-auto-emphasis--current-region-bounds)
+ (setq org-auto-emphasis-= -current-region-bounds nil))
+ =C2=A0;; Unhide emphasis markers for the = current region.
+ =C2=A0(let* ((s (org-auto-emphasis--get-prop-as-list &= #39;org-emph-start))
+ (e (and s (org-auto-emphasis--get-prop-as-list &= #39;org-emph-end)))
+ (s (and e (apply #'min s)))
+ (e (and s (= apply #'max e))))
+ =C2=A0 =C2=A0(when e
+ =C2=A0 =C2=A0 =C2=A0(w= ith-silent-modifications
+ (setq org-auto-emphasis--current-region-bound= s (list s e))
+ (remove-text-properties s (1+ s) '(invisible org-lin= k))
+ (remove-text-properties (1- e) e '(invisible org-link))))))+
+(define-minor-mode org-auto-emphasis-mode
+ =C2=A0"Toggle Or= g Auto Emphasis mode.
+This mode, when enabled, unhides emphasis markers= for the text
+at point, depending on the value of
+`org-auto-emphasi= s-unhide-at-point'. With a prefix argument ARG,
+enable Org Auto Emp= hasis mode if ARG is positive, and disable it
+otherwise.=C2=A0 If calle= d from Lisp, enable the mode if ARG is
+omitted or nil.
+
+To enab= le this in all Org files, add the following line to init.el:
+
+ =C2= =A0(add-hook \\=3D'org-mode #\\=3D'org-auto-emphasis-mode)
+&quo= t;
+ =C2=A0:init-value nil
+ =C2=A0(if org-auto-emphasis-mode
+ = =C2=A0 =C2=A0 =C2=A0;; Turn on
+ =C2=A0 =C2=A0 =C2=A0(progn
+ =C2=A0 = =C2=A0 =C2=A0 =C2=A0(setq-local font-lock-extra-managed-props
+ =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(append font-= lock-extra-managed-props
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0'(org-emph-start or= g-emph-end)))
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0(when org-auto-emphasis-unhid= e-at-point
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(add-hook 'post-comma= nd-hook
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0#'org-auto-emphasis--post-command-hook nil t))
+ =C2=A0 =C2= =A0 =C2=A0 =C2=A0(font-lock-flush))
+ =C2=A0 =C2=A0;; Turn off
+ =C2= =A0 =C2=A0(remove-hook 'post-command-hook #'org-auto-emphasis--post= -command-hook t)))
+
=C2=A0(defun org-emphasize (&optional char)<= br>=C2=A0 =C2=A0"Insert or change an emphasis, i.e. a font like bold o= r italic.
=C2=A0If there is an active region, change that region to a ne= w emphasis.
--
2.17.1

=C2=A0
--0000000000003d7a1105a8d3f6da-- --0000000000003d7a1405a8d3f6dc Content-Type: application/x-patch; name="0001-Add-mode-for-automatically-unhiding-emphasis-markers.patch" Content-Disposition: attachment; filename="0001-Add-mode-for-automatically-unhiding-emphasis-markers.patch" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_kbtaknyi0 RnJvbSAwZTJhNDZjMDFhZDQxMmQ1OWIzYTY3YTRiYTgyOTI5MTRlNzAwMTAyIE1vbiBTZXAgMTcg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ZW1waGFz aXMtLXBvc3QtY29tbWFuZC1ob29rIG5pbCB0KSkKKyAgICAgICAgKGZvbnQtbG9jay1mbHVzaCkp CisgICAgOzsgVHVybiBvZmYKKyAgICAocmVtb3ZlLWhvb2sgJ3Bvc3QtY29tbWFuZC1ob29rICMn b3JnLWF1dG8tZW1waGFzaXMtLXBvc3QtY29tbWFuZC1ob29rIHQpKSkKKwogKGRlZnVuIG9yZy1l bXBoYXNpemUgKCZvcHRpb25hbCBjaGFyKQogICAiSW5zZXJ0IG9yIGNoYW5nZSBhbiBlbXBoYXNp cywgaS5lLiBhIGZvbnQgbGlrZSBib2xkIG9yIGl0YWxpYy4KIElmIHRoZXJlIGlzIGFuIGFjdGl2 ZSByZWdpb24sIGNoYW5nZSB0aGF0IHJlZ2lvbiB0byBhIG5ldyBlbXBoYXNpcy4KLS0gCjIuMTcu MQoK --0000000000003d7a1405a8d3f6dc--