all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Re: [Emacs-diffs] master 188f657: Fix false negatives in tex--prettify-symbols-compose-p.
       [not found] ` <E1ZfaB6-0004p6-FL@vcs.savannah.gnu.org>
@ 2015-09-26  4:54   ` Stefan Monnier
  2015-09-26  5:36     ` Tassilo Horn
  2015-09-29 11:29   ` Artur Malabarba
  1 sibling, 1 reply; 19+ messages in thread
From: Stefan Monnier @ 2015-09-26  4:54 UTC (permalink / raw)
  To: emacs-devel; +Cc: Tassilo Horn

> -          ;; Don't compose inside verbatim blocks!
> -          (nth 8 (syntax-ppss))
[...]
> +          ;; Don't compose inside verbatim blocks.
> +          (let* ((face (get-text-property end 'face))
> +                 (faces (if (consp face) face (list face))))
> +            (or (memq 'tex-verbatim faces)
> +                (memq 'font-latex-verbatim-face faces)))))))
 
Rather than check the `face' property, I think it'd be more robust to
use the (syntax-ppss) data.  Since tex-env-mark uses "< c" for the
syntax of \begin{verbatim}, A test like

   (eq 2 (nth 7 (syntax-ppss)))

should do the trick.


        Stefan "at least for the non-font-latex case"



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

* Re: [Emacs-diffs] master 188f657: Fix false negatives in tex--prettify-symbols-compose-p.
  2015-09-26  4:54   ` [Emacs-diffs] master 188f657: Fix false negatives in tex--prettify-symbols-compose-p Stefan Monnier
@ 2015-09-26  5:36     ` Tassilo Horn
  2015-09-26  5:46       ` Tassilo Horn
  0 siblings, 1 reply; 19+ messages in thread
From: Tassilo Horn @ 2015-09-26  5:36 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>> -          ;; Don't compose inside verbatim blocks!
>> -          (nth 8 (syntax-ppss))
> [...]
>> +          ;; Don't compose inside verbatim blocks.
>> +          (let* ((face (get-text-property end 'face))
>> +                 (faces (if (consp face) face (list face))))
>> +            (or (memq 'tex-verbatim faces)
>> +                (memq 'font-latex-verbatim-face faces)))))))
>  
> Rather than check the `face' property, I think it'd be more robust to
> use the (syntax-ppss) data.  Since tex-env-mark uses "< c" for the
> syntax of \begin{verbatim}, A test like
>
>    (eq 2 (nth 7 (syntax-ppss)))
>
> should do the trick.
>
>         Stefan "at least for the non-font-latex case"

Yes, but only for the non-font-latex case.  With font-latex, using the
8th ppss data will omit prettification in $...$ because those are treated
as strings at fontification time, and it also doesn't give comment
syntax to verbatim stuff.

But if you prefer, I can use your check in
`tex--prettify-symbols-compose-p' and have a font-latex-specific
`prettify-symbols-compose-predicate' in AUCTeX which would go like

  (and (tex--prettify-symbols-compose-p start end match)
       (not (let ((face (get-text-property end 'face)))       
              (if (consp face)
                (memq 'font-latex-verbatim-face face)
              (eq face 'font-latex-verbatim-face))))

Bye,
Tassilo



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

* Re: [Emacs-diffs] master 188f657: Fix false negatives in tex--prettify-symbols-compose-p.
  2015-09-26  5:36     ` Tassilo Horn
@ 2015-09-26  5:46       ` Tassilo Horn
  0 siblings, 0 replies; 19+ messages in thread
From: Tassilo Horn @ 2015-09-26  5:46 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

Tassilo Horn <tsdh@gnu.org> writes:

> But if you prefer, I can use your check in
> `tex--prettify-symbols-compose-p' and have a font-latex-specific
> `prettify-symbols-compose-predicate' in AUCTeX

That's what I did now.

Bye,
Tassilo



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

* Re: [Emacs-diffs] master 188f657: Fix false negatives in tex--prettify-symbols-compose-p.
       [not found] ` <E1ZfaB6-0004p6-FL@vcs.savannah.gnu.org>
  2015-09-26  4:54   ` [Emacs-diffs] master 188f657: Fix false negatives in tex--prettify-symbols-compose-p Stefan Monnier
@ 2015-09-29 11:29   ` Artur Malabarba
  2015-09-29 12:31     ` Tassilo Horn
  1 sibling, 1 reply; 19+ messages in thread
From: Artur Malabarba @ 2015-09-29 11:29 UTC (permalink / raw)
  To: emacs-devel, Tassilo Horn

Would it be possible to also use `tex--prettify-symbols-compose-p' to
avoid composing the symbol-at-point? (perhaps by checking window-point
or something). That would toggleable by a user-option, of course.

Or maybe that feature should be implemented in `prettify-symbols-mode' itself.

2015-09-25 22:05 GMT+01:00 Tassilo Horn <tsdh@gnu.org>:
> branch: master
> commit 188f657a827b04d72376f8b483c7d4b678e96fac
> Author: Tassilo Horn <tsdh@gnu.org>
> Commit: Tassilo Horn <tsdh@gnu.org>
>
>     Fix false negatives in tex--prettify-symbols-compose-p.
>
>     * lisp/textmodes/tex-mode.el (tex--prettify-symbols-compose-p): Fix some
>     false negatives.



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

* Re: [Emacs-diffs] master 188f657: Fix false negatives in tex--prettify-symbols-compose-p.
  2015-09-29 11:29   ` Artur Malabarba
@ 2015-09-29 12:31     ` Tassilo Horn
  2015-09-29 13:14       ` Artur Malabarba
  2015-09-29 19:46       ` Tassilo Horn
  0 siblings, 2 replies; 19+ messages in thread
From: Tassilo Horn @ 2015-09-29 12:31 UTC (permalink / raw)
  To: Artur Malabarba; +Cc: emacs-devel

Artur Malabarba <bruce.connor.am@gmail.com> writes:

> Would it be possible to also use `tex--prettify-symbols-compose-p' to
> avoid composing the symbol-at-point? (perhaps by checking window-point
> or something). That would toggleable by a user-option, of course.

You mean, when point enters a prettified symbol the original text would
be shown?  Indeed, that sounds like a neat idea.  If I think about it, I
don't use prettification in LaTeX exactly because there are so many
prettified symbols which partly overlap and then editing becomes
cumbersome, e.g., when deleting a char from the prettified integral \int
you'll get the prettification of the set membership relation \in.

> Or maybe that feature should be implemented in `prettify-symbols-mode'
> itself.

Yes, I think the only thing to be done would be to change the

  (if (funcall prettify-symbols-compose-predicate start end match) ...

in `prettify-symbols--compose-symbol' to

  (if (and (or prettify-symbols-compose-at-point
               (< (window-point) start)
               (> (window-point) end))
           (funcall prettify-symbols-compose-predicate start end match)))

where `prettify-symbols-compose-at-point' would be the user option.

I'll try that out when I find some time.  If you want, you can of course
give it a shot yourself.

Bye,
Tassilo

> 2015-09-25 22:05 GMT+01:00 Tassilo Horn <tsdh@gnu.org>:
>> branch: master
>> commit 188f657a827b04d72376f8b483c7d4b678e96fac
>> Author: Tassilo Horn <tsdh@gnu.org>
>> Commit: Tassilo Horn <tsdh@gnu.org>
>>
>>     Fix false negatives in tex--prettify-symbols-compose-p.
>>
>>     * lisp/textmodes/tex-mode.el (tex--prettify-symbols-compose-p): Fix some
>>     false negatives.



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

* Re: [Emacs-diffs] master 188f657: Fix false negatives in tex--prettify-symbols-compose-p.
  2015-09-29 12:31     ` Tassilo Horn
@ 2015-09-29 13:14       ` Artur Malabarba
  2015-09-30  6:46         ` Tassilo Horn
       [not found]         ` <B393F5AD12955C48A84FFB08032CD04F6C218AED@ECS-EXG-P-MB01.win.lanl.gov>
  2015-09-29 19:46       ` Tassilo Horn
  1 sibling, 2 replies; 19+ messages in thread
From: Artur Malabarba @ 2015-09-29 13:14 UTC (permalink / raw)
  To: Artur Malabarba, emacs-devel

2015-09-29 13:31 GMT+01:00 Tassilo Horn <tsdh@gnu.org>:
> Artur Malabarba <bruce.connor.am@gmail.com> writes:
>
>> Would it be possible to also use `tex--prettify-symbols-compose-p' to
>> avoid composing the symbol-at-point? (perhaps by checking window-point
>> or something). That would toggleable by a user-option, of course.
>
> You mean, when point enters a prettified symbol the original text would
> be shown?  Indeed, that sounds like a neat idea.  If I think about it, I
> don't use prettification in LaTeX exactly because there are so many
> prettified symbols which partly overlap and then editing becomes
> cumbersome, e.g., when deleting a char from the prettified integral \int
> you'll get the prettification of the set membership relation \in.

Yes. I like prettify-symbols quite a bit, but this slight
inconvenience when editing symbols prevents me from using the mode
right now.

>> Or maybe that feature should be implemented in `prettify-symbols-mode'
>> itself.
>
> Yes, I think the only thing to be done would be to change the
>
>   (if (funcall prettify-symbols-compose-predicate start end match) ...
>
> in `prettify-symbols--compose-symbol' to
>
>   (if (and (or prettify-symbols-compose-at-point
>                (< (window-point) start)
>                (> (window-point) end))
>            (funcall prettify-symbols-compose-predicate start end match)))

I was actually thinking of using `<=', so that placing point at the
edges would already be enough.

> where `prettify-symbols-compose-at-point' would be the user option.

I tried something similar, and unfortunately it's not that simple.
Firstly, (window-point) didn't seem to work as expected here, so I had
to define a variable in font-lock-mode to hold the value of (point)
before fontification started.

After doing that, the feature sort of works while you're writing. That
is, it doesn't prettify a symbol you've just written, but it does
prettify a symbol after you hit SPC, which is nice.
However, it does not work while navigating. That is, when you move
point to a prettified symbol, it doesn't get decomposed.

Then I tried adding a post-command-hook function to invalidate the
font-locking at point. This correctly decomposes a symbol when you
move the cursor to it, but it's still not perfect. When you move the
cursor *out* of the symbol, if you move far enough, the symbol doesn't
get prettified again until you edit something close to it.



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

* Re: [Emacs-diffs] master 188f657: Fix false negatives in tex--prettify-symbols-compose-p.
  2015-09-29 12:31     ` Tassilo Horn
  2015-09-29 13:14       ` Artur Malabarba
@ 2015-09-29 19:46       ` Tassilo Horn
  1 sibling, 0 replies; 19+ messages in thread
From: Tassilo Horn @ 2015-09-29 19:46 UTC (permalink / raw)
  To: Artur Malabarba; +Cc: emacs-devel

Tassilo Horn <tsdh@gnu.org> writes:

Hi Artur,

>> Would it be possible to also use `tex--prettify-symbols-compose-p' to
>> avoid composing the symbol-at-point? (perhaps by checking
>> window-point or something). That would toggleable by a user-option,
>> of course.
>
> You mean, when point enters a prettified symbol the original text
> would be shown?  Indeed, that sounds like a neat idea.  If I think
> about it, I don't use prettification in LaTeX exactly because there
> are so many prettified symbols which partly overlap and then editing
> becomes cumbersome, e.g., when deleting a char from the prettified
> integral \int you'll get the prettification of the set membership
> relation \in.
>
>> Or maybe that feature should be implemented in `prettify-symbols-mode'
>> itself.
>
> Yes, I think the only thing to be done would be to change the
>
>   (if (funcall prettify-symbols-compose-predicate start end match) ...
>
> in `prettify-symbols--compose-symbol' to
>
>   (if (and (or prettify-symbols-compose-at-point
>                (< (window-point) start)
>                (> (window-point) end))
>            (funcall prettify-symbols-compose-predicate start end match)))
>
> where `prettify-symbols-compose-at-point' would be the user option.

Well, this approach didn't work because during font-lock both `point'
and `window-point' equal `end', i.e., the end of the match of the search
font-lock performed.

Then I experimented with the `point-entered' and `point-left' text
properties but apparently the functions I added there were never ever
called.  On the internets I have read that these two props are much more
low-level than what one would expect and in general it would be better
to track point in a `post-command-hook'.

So that's what I did, and the following patch works fine for me.
Comments welcome!

--8<---------------cut here---------------start------------->8---
prettify-symbols-ext 7c2ef9b8948df4c05d0c0aa28d85a128f975e453
Author:     Tassilo Horn <tsdh@gnu.org>
AuthorDate: Tue Sep 29 21:34:18 2015 +0200
Commit:     Tassilo Horn <tsdh@gnu.org>
CommitDate: Tue Sep 29 21:34:18 2015 +0200

Parent:     888d644 * net/shr.el (shr-colorize-region): Don't do it on a system not supporting 256 above colors (bug#21557).
Merged:     master prettify-symbols-ext
Containing: prettify-symbols-ext
Follows:    emacs-24.5-rc3-fixed (6045)

Implement unprettification of symbol at point

* lisp/progmodes/prog-mode.el: Implement feature for unprettifying the
symbol at point.
(prettify-symbols--current-symbol-bounds): New variable.
(prettify-symbols--post-command-hook): New function.
(prettify-symbols-unprettify-at-point): New defcustom.
(prettify-symbols-mode): Use it.
(prettify-symbols--compose-symbol): Use them.

1 file changed, 36 insertions(+), 3 deletions(-)
lisp/progmodes/prog-mode.el | 39 ++++++++++++++++++++++++++++++++++++---

modified   lisp/progmodes/prog-mode.el
@@ -161,13 +161,20 @@ prettify-symbols--compose-symbol
   (let ((start (match-beginning 0))
         (end (match-end 0))
         (match (match-string 0)))
-    (if (funcall prettify-symbols-compose-predicate start end match)
+    (if (and (not (equal prettify-symbols--current-symbol-bounds (list start end)))
+             (funcall prettify-symbols-compose-predicate start end match))
         ;; That's a symbol alright, so add the composition.
-        (compose-region start end (cdr (assoc match alist)))
+        (progn
+          (compose-region start end (cdr (assoc match alist)))
+          (add-text-properties
+           start end
+           `(prettify-symbols-start ,start prettify-symbols-end ,end)))
       ;; No composition for you.  Let's actually remove any
       ;; composition we may have added earlier and which is now
       ;; incorrect.
-      (remove-text-properties start end '(composition))))
+      (remove-text-properties start end '(composition
+                                          prettify-symbols-start
+                                          prettify-symbols-end))))
   ;; Return nil because we're not adding any face property.
   nil)
 
@@ -179,6 +186,29 @@ prettify-symbols--make-keywords
 
 (defvar-local prettify-symbols--keywords nil)
 
+(defvar-local prettify-symbols--current-symbol-bounds nil)
+
+(defun prettify-symbols--post-command-hook ()
+  (if-let ((_ (get-text-property (point) 'composition))
+           (s (get-text-property (point) 'prettify-symbols-start))
+           (e (get-text-property (point) 'prettify-symbols-end)))
+      (progn
+        (setq prettify-symbols--current-symbol-bounds (list s e))
+        (remove-text-properties s e '(composition)))
+    (when (and prettify-symbols--current-symbol-bounds
+               (or (< (point) (car prettify-symbols--current-symbol-bounds))
+                   (>= (point) (cadr prettify-symbols--current-symbol-bounds))))
+      (apply #'font-lock-flush prettify-symbols--current-symbol-bounds)
+      (setq prettify-symbols--current-symbol-bounds nil))))
+
+(defcustom prettify-symbols-unprettify-at-point t
+  "If non-nil, show the non-prettified version of a symbol when point is on it.
+The prettification will be reapplied as soon as point moves away
+from the symbol.  If set to nil, the prettification persists even
+when point is on the symbol."
+  :type 'boolean
+  :group 'prog-mode)
+
 ;;;###autoload
 (define-minor-mode prettify-symbols-mode
   "Toggle Prettify Symbols mode.
@@ -206,6 +236,9 @@ prettify-symbols-mode
         (font-lock-add-keywords nil prettify-symbols--keywords)
         (setq-local font-lock-extra-managed-props
                     (cons 'composition font-lock-extra-managed-props))
+        (when prettify-symbols-unprettify-at-point
+          (add-hook 'post-command-hook
+                    #'prettify-symbols--post-command-hook nil t))
         (font-lock-flush))
     ;; Turn off
     (when prettify-symbols--keywords

--8<---------------cut here---------------end--------------->8---

Bye,
Tassilo



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

* Re: [Emacs-diffs] master 188f657: Fix false negatives in tex--prettify-symbols-compose-p.
  2015-09-29 13:14       ` Artur Malabarba
@ 2015-09-30  6:46         ` Tassilo Horn
  2015-09-30  7:48           ` Artur Malabarba
       [not found]         ` <B393F5AD12955C48A84FFB08032CD04F6C218AED@ECS-EXG-P-MB01.win.lanl.gov>
  1 sibling, 1 reply; 19+ messages in thread
From: Tassilo Horn @ 2015-09-30  6:46 UTC (permalink / raw)
  To: Artur Malabarba; +Cc: emacs-devel

Artur Malabarba <bruce.connor.am@gmail.com> writes:

Hi Artur,

>> where `prettify-symbols-compose-at-point' would be the user option.
>
> I tried something similar, and unfortunately it's not that simple.
> Firstly, (window-point) didn't seem to work as expected here, so I had
> to define a variable in font-lock-mode to hold the value of (point)
> before fontification started.
>
> After doing that, the feature sort of works while you're writing. That
> is, it doesn't prettify a symbol you've just written, but it does
> prettify a symbol after you hit SPC, which is nice.  However, it does
> not work while navigating. That is, when you move point to a
> prettified symbol, it doesn't get decomposed.
>
> Then I tried adding a post-command-hook function to invalidate the
> font-locking at point. This correctly decomposes a symbol when you
> move the cursor to it, but it's still not perfect. When you move the
> cursor *out* of the symbol, if you move far enough, the symbol doesn't
> get prettified again until you edit something close to it.

Hehe, seems we tried implementing that feature at the same time and both
fell into the very same traps.  Did you see my other mail?  I have
gotten it working nicely right yesterday.  Right now I did some minor
changes, and that's the current version of the patch:

Comments welcome!

--8<---------------cut here---------------start------------->8---
1 file changed, 39 insertions(+), 4 deletions(-)
lisp/progmodes/prog-mode.el | 43 +++++++++++++++++++++++++++++++++++++++----

modified   lisp/progmodes/prog-mode.el
@@ -29,7 +29,8 @@
 
 ;;; Code:
 
-(eval-when-compile (require 'cl-lib))
+(eval-when-compile (require 'cl-lib)
+                   (require 'subr-x))
 
 (defgroup prog-mode nil
   "Generic programming mode, from which others derive."
@@ -161,13 +162,20 @@ prettify-symbols--compose-symbol
   (let ((start (match-beginning 0))
         (end (match-end 0))
         (match (match-string 0)))
-    (if (funcall prettify-symbols-compose-predicate start end match)
+    (if (and (not (equal prettify-symbols--current-symbol-bounds (list start end)))
+             (funcall prettify-symbols-compose-predicate start end match))
         ;; That's a symbol alright, so add the composition.
-        (compose-region start end (cdr (assoc match alist)))
+        (progn
+          (compose-region start end (cdr (assoc match alist)))
+          (add-text-properties
+           start end
+           `(prettify-symbols-start ,start prettify-symbols-end ,end)))
       ;; No composition for you.  Let's actually remove any
       ;; composition we may have added earlier and which is now
       ;; incorrect.
-      (remove-text-properties start end '(composition))))
+      (remove-text-properties start end '(composition
+                                          prettify-symbols-start
+                                          prettify-symbols-end))))
   ;; Return nil because we're not adding any face property.
   nil)
 
@@ -179,6 +187,29 @@ prettify-symbols--make-keywords
 
 (defvar-local prettify-symbols--keywords nil)
 
+(defvar-local prettify-symbols--current-symbol-bounds nil)
+
+(defun prettify-symbols--post-command-hook ()
+  (if-let ((c (get-text-property (point) 'composition))
+           (s (get-text-property (point) 'prettify-symbols-start))
+           (e (get-text-property (point) 'prettify-symbols-end)))
+      (progn
+        (setq prettify-symbols--current-symbol-bounds (list s e))
+        (remove-text-properties s e '(composition)))
+    (when (and prettify-symbols--current-symbol-bounds
+               (or (< (point) (car prettify-symbols--current-symbol-bounds))
+                   (>= (point) (cadr prettify-symbols--current-symbol-bounds))))
+      (apply #'font-lock-flush prettify-symbols--current-symbol-bounds)
+      (setq prettify-symbols--current-symbol-bounds nil))))
+
+(defcustom prettify-symbols-unprettify-at-point t
+  "If non-nil, show the non-prettified version of a symbol when point is on it.
+The prettification will be reapplied as soon as point moves away
+from the symbol.  If set to nil, the prettification persists even
+when point is on the symbol."
+  :type 'boolean
+  :group 'prog-mode)
+
 ;;;###autoload
 (define-minor-mode prettify-symbols-mode
   "Toggle Prettify Symbols mode.
@@ -206,8 +237,12 @@ prettify-symbols-mode
         (font-lock-add-keywords nil prettify-symbols--keywords)
         (setq-local font-lock-extra-managed-props
                     (cons 'composition font-lock-extra-managed-props))
+        (when prettify-symbols-unprettify-at-point
+          (add-hook 'post-command-hook
+                    #'prettify-symbols--post-command-hook nil t))
         (font-lock-flush))
     ;; Turn off
+    (remove-hook 'post-command-hook #'prettify-symbols--post-command-hook t)
     (when prettify-symbols--keywords
       (font-lock-remove-keywords nil prettify-symbols--keywords)
       (setq prettify-symbols--keywords nil))
--8<---------------cut here---------------end--------------->8---

Bye,
Tassilo



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

* Re: [Emacs-diffs] master 188f657: Fix false negatives in tex--prettify-symbols-compose-p.
  2015-09-30  6:46         ` Tassilo Horn
@ 2015-09-30  7:48           ` Artur Malabarba
  0 siblings, 0 replies; 19+ messages in thread
From: Artur Malabarba @ 2015-09-30  7:48 UTC (permalink / raw)
  To: emacs-devel

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

Hi Tassilo,

Nice!

The code looks good to me, I'll give it a try later today. Looks like you
went a bit further than me to overcome the traps.

On 30 Sep 2015 7:46 am, "Tassilo Horn" <tsdh@gnu.org> wrote:

> Artur Malabarba <bruce.connor.am@gmail.com> writes:
>
> Hi Artur,
>
> >> where `prettify-symbols-compose-at-point' would be the user option.
> >
> > I tried something similar, and unfortunately it's not that simple.
> > Firstly, (window-point) didn't seem to work as expected here, so I had
> > to define a variable in font-lock-mode to hold the value of (point)
> > before fontification started.
> >
> > After doing that, the feature sort of works while you're writing. That
> > is, it doesn't prettify a symbol you've just written, but it does
> > prettify a symbol after you hit SPC, which is nice.  However, it does
> > not work while navigating. That is, when you move point to a
> > prettified symbol, it doesn't get decomposed.
> >
> > Then I tried adding a post-command-hook function to invalidate the
> > font-locking at point. This correctly decomposes a symbol when you
> > move the cursor to it, but it's still not perfect. When you move the
> > cursor *out* of the symbol, if you move far enough, the symbol doesn't
> > get prettified again until you edit something close to it.
>
> Hehe, seems we tried implementing that feature at the same time and both
> fell into the very same traps.  Did you see my other mail?  I have
> gotten it working nicely right yesterday.  Right now I did some minor
> changes, and that's the current version of the patch:
>
> Comments welcome!
>
> --8<---------------cut here---------------start------------->8---
> 1 file changed, 39 insertions(+), 4 deletions(-)
> lisp/progmodes/prog-mode.el | 43
+++++++++++++++++++++++++++++++++++++++----
>
> modified   lisp/progmodes/prog-mode.el
> @@ -29,7 +29,8 @@
>
>  ;;; Code:
>
> -(eval-when-compile (require 'cl-lib))
> +(eval-when-compile (require 'cl-lib)
> +                   (require 'subr-x))
>
>  (defgroup prog-mode nil
>    "Generic programming mode, from which others derive."
> @@ -161,13 +162,20 @@ prettify-symbols--compose-symbol
>    (let ((start (match-beginning 0))
>          (end (match-end 0))
>          (match (match-string 0)))
> -    (if (funcall prettify-symbols-compose-predicate start end match)
> +    (if (and (not (equal prettify-symbols--current-symbol-bounds (list
start end)))
> +             (funcall prettify-symbols-compose-predicate start end
match))
>          ;; That's a symbol alright, so add the composition.
> -        (compose-region start end (cdr (assoc match alist)))
> +        (progn
> +          (compose-region start end (cdr (assoc match alist)))
> +          (add-text-properties
> +           start end
> +           `(prettify-symbols-start ,start prettify-symbols-end ,end)))
>        ;; No composition for you.  Let's actually remove any
>        ;; composition we may have added earlier and which is now
>        ;; incorrect.
> -      (remove-text-properties start end '(composition))))
> +      (remove-text-properties start end '(composition
> +                                          prettify-symbols-start
> +                                          prettify-symbols-end))))
>    ;; Return nil because we're not adding any face property.
>    nil)
>
> @@ -179,6 +187,29 @@ prettify-symbols--make-keywords
>
>  (defvar-local prettify-symbols--keywords nil)
>
> +(defvar-local prettify-symbols--current-symbol-bounds nil)
> +
> +(defun prettify-symbols--post-command-hook ()
> +  (if-let ((c (get-text-property (point) 'composition))
> +           (s (get-text-property (point) 'prettify-symbols-start))
> +           (e (get-text-property (point) 'prettify-symbols-end)))
> +      (progn
> +        (setq prettify-symbols--current-symbol-bounds (list s e))
> +        (remove-text-properties s e '(composition)))
> +    (when (and prettify-symbols--current-symbol-bounds
> +               (or (< (point) (car
prettify-symbols--current-symbol-bounds))
> +                   (>= (point) (cadr
prettify-symbols--current-symbol-bounds))))
> +      (apply #'font-lock-flush prettify-symbols--current-symbol-bounds)
> +      (setq prettify-symbols--current-symbol-bounds nil))))
> +
> +(defcustom prettify-symbols-unprettify-at-point t
> +  "If non-nil, show the non-prettified version of a symbol when point is
on it.
> +The prettification will be reapplied as soon as point moves away
> +from the symbol.  If set to nil, the prettification persists even
> +when point is on the symbol."
> +  :type 'boolean
> +  :group 'prog-mode)
> +
>  ;;;###autoload
>  (define-minor-mode prettify-symbols-mode
>    "Toggle Prettify Symbols mode.
> @@ -206,8 +237,12 @@ prettify-symbols-mode
>          (font-lock-add-keywords nil prettify-symbols--keywords)
>          (setq-local font-lock-extra-managed-props
>                      (cons 'composition font-lock-extra-managed-props))
> +        (when prettify-symbols-unprettify-at-point
> +          (add-hook 'post-command-hook
> +                    #'prettify-symbols--post-command-hook nil t))
>          (font-lock-flush))
>      ;; Turn off
> +    (remove-hook 'post-command-hook
#'prettify-symbols--post-command-hook t)
>      (when prettify-symbols--keywords
>        (font-lock-remove-keywords nil prettify-symbols--keywords)
>        (setq prettify-symbols--keywords nil))
> --8<---------------cut here---------------end--------------->8---
>
> Bye,
> Tassilo

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

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

* RE: [Emacs-diffs] master 188f657: Fix false negatives in tex--prettify-symbols-compose-p.
       [not found]         ` <B393F5AD12955C48A84FFB08032CD04F6C218AED@ECS-EXG-P-MB01.win.lanl.gov>
@ 2015-09-30  7:51           ` Artur Malabarba
  2015-09-30  8:59             ` Tassilo Horn
  0 siblings, 1 reply; 19+ messages in thread
From: Artur Malabarba @ 2015-09-30  7:51 UTC (permalink / raw)
  To: Davis Herring, emacs-devel, Tassilo Horn

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

On 30 Sep 2015 4:12 am, "Herring, Davis" <herring@lanl.gov> wrote:
>
> Could mimicking (better: merging with) the approach of reveal-mode help?
>
> Davis

Now that Tassilo seems to have it working, I don't think it's worth
mimicking something else. However, if the feature can be simplified by
merging with reveal mode then that would surely be nice.

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

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

* Re: [Emacs-diffs] master 188f657: Fix false negatives in tex--prettify-symbols-compose-p.
  2015-09-30  7:51           ` Artur Malabarba
@ 2015-09-30  8:59             ` Tassilo Horn
  2015-09-30 10:08               ` Artur Malabarba
  0 siblings, 1 reply; 19+ messages in thread
From: Tassilo Horn @ 2015-09-30  8:59 UTC (permalink / raw)
  To: Artur Malabarba; +Cc: emacs-devel

Artur Malabarba <bruce.connor.am@gmail.com> writes:

>> Could mimicking (better: merging with) the approach of reveal-mode
>> help?
>
> Now that Tassilo seems to have it working, I don't think it's worth
> mimicking something else.  However, if the feature can be simplified
> by merging with reveal mode then that would surely be nice.

I didn't get Davis email until now (and it seems that mails from or to
emacs-devel are somehow deferred; do you have such issues, too?) but had
a quick at reveal-mode.  We can't use that because `reveal-mode' is
specialized for revealing overlays whereas `prettify-symbols-mode' uses
text properties.

Bye,
Tassilo



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

* Re: [Emacs-diffs] master 188f657: Fix false negatives in tex--prettify-symbols-compose-p.
  2015-09-30  8:59             ` Tassilo Horn
@ 2015-09-30 10:08               ` Artur Malabarba
  2015-09-30 10:45                 ` Tassilo Horn
  0 siblings, 1 reply; 19+ messages in thread
From: Artur Malabarba @ 2015-09-30 10:08 UTC (permalink / raw)
  To: Artur Malabarba, Davis Herring, emacs-devel, Tassilo Horn

2015-09-30 9:59 GMT+01:00 Tassilo Horn <tsdh@gnu.org>:
> Artur Malabarba <bruce.connor.am@gmail.com> writes:
>
>>> Could mimicking (better: merging with) the approach of reveal-mode
>>> help?
>>
>> Now that Tassilo seems to have it working, I don't think it's worth
>> mimicking something else.  However, if the feature can be simplified
>> by merging with reveal mode then that would surely be nice.
>
> I didn't get Davis email until now

He accidentally sent it only to me (instead of to the list).

> (and it seems that mails from or to
> emacs-devel are somehow deferred; do you have such issues, too?)

I have noticed that when I try to "reply-all" one of your emails your
address is never included in the To: field (I added it manually now).
The list address does get included, though, so you probably receive
the emails anyway.

> We can't use that because `reveal-mode' is
> specialized for revealing overlays whereas `prettify-symbols-mode' uses
> text properties.

Alright. I tested the code now and it works well. My only suggestion
would be to change this:
  (< (point) (car prettify-symbols--current-symbol-bounds))
to this:
  (<= (point) (car prettify-symbols--current-symbol-bounds))
But I guess that's more of a personal preference.

Either way I think it looks good to merge.

Cheers



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

* Re: [Emacs-diffs] master 188f657: Fix false negatives in tex--prettify-symbols-compose-p.
  2015-09-30 10:08               ` Artur Malabarba
@ 2015-09-30 10:45                 ` Tassilo Horn
  2015-09-30 11:12                   ` Artur Malabarba
  2015-10-01  1:19                   ` Artur Malabarba
  0 siblings, 2 replies; 19+ messages in thread
From: Tassilo Horn @ 2015-09-30 10:45 UTC (permalink / raw)
  To: Artur Malabarba; +Cc: emacs-devel

Artur Malabarba <bruce.connor.am@gmail.com> writes:

>>>> Could mimicking (better: merging with) the approach of reveal-mode
>>>> help?
>>>
>>> Now that Tassilo seems to have it working, I don't think it's worth
>>> mimicking something else.  However, if the feature can be simplified
>>> by merging with reveal mode then that would surely be nice.
>>
>> I didn't get Davis email until now
>
> He accidentally sent it only to me (instead of to the list).

Ah, ok.

>> (and it seems that mails from or to
>> emacs-devel are somehow deferred; do you have such issues, too?)
>
> I have noticed that when I try to "reply-all" one of your emails your
> address is never included in the To: field (I added it manually now).

Hm, that probably depends on your mail client.  When I follow up to your
mails on emacs-devel using Gnus, you'll be in To and emacs-devel in Cc.

> The list address does get included, though, so you probably receive
> the emails anyway.

Yes, the problem is only that mails directed to my email address are
delivered immediately while I haven't received mail from emacs-devel for
several hours.  This includes for example your mail I'm just replying
to...

>> We can't use that because `reveal-mode' is specialized for revealing
>> overlays whereas `prettify-symbols-mode' uses text properties.
>
> Alright. I tested the code now and it works well. My only suggestion
> would be to change this:
>   (< (point) (car prettify-symbols--current-symbol-bounds))
> to this:
>   (<= (point) (car prettify-symbols--current-symbol-bounds))
> But I guess that's more of a personal preference.

Yes, I think so too.  But feel free to add that feature, e.g., by having
another possibile value for `prettify-symbols-unprettify-at-point'.

> Either way I think it looks good to merge.

Done and thanks!
Tassilo



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

* Re: [Emacs-diffs] master 188f657: Fix false negatives in tex--prettify-symbols-compose-p.
  2015-09-30 10:45                 ` Tassilo Horn
@ 2015-09-30 11:12                   ` Artur Malabarba
  2015-09-30 11:29                     ` Tassilo Horn
  2015-10-01  1:19                   ` Artur Malabarba
  1 sibling, 1 reply; 19+ messages in thread
From: Artur Malabarba @ 2015-09-30 11:12 UTC (permalink / raw)
  To: Artur Malabarba, emacs-devel, Tassilo Horn

2015-09-30 11:45 GMT+01:00 Tassilo Horn <tsdh@gnu.org>:
> Hm, that probably depends on your mail client.  When I follow up to your
> mails on emacs-devel using Gnus, you'll be in To and emacs-devel in Cc.

It's not a general thing. I meant *Your* address doesn't get included.
Everyone else's does. It's probably that your messages arrive with a
different "reply-to:" header.

For instance, if I try to "Reply All" one of your messages, then
Davis's address is included on the To: field but yours isn't.
OTOH, if I "reply all" on Stefan's message, both you and Stefan will
be included in the To field.

> Done and thanks!

Thank you!



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

* Re: [Emacs-diffs] master 188f657: Fix false negatives in tex--prettify-symbols-compose-p.
  2015-09-30 11:12                   ` Artur Malabarba
@ 2015-09-30 11:29                     ` Tassilo Horn
  2015-10-01  1:17                       ` Artur Malabarba
  0 siblings, 1 reply; 19+ messages in thread
From: Tassilo Horn @ 2015-09-30 11:29 UTC (permalink / raw)
  To: Artur Malabarba; +Cc: emacs-devel

Artur Malabarba <bruce.connor.am@gmail.com> writes:

>> Hm, that probably depends on your mail client.  When I follow up to your
>> mails on emacs-devel using Gnus, you'll be in To and emacs-devel in Cc.
>
> It's not a general thing. I meant *Your* address doesn't get included.
> Everyone else's does. It's probably that your messages arrive with a
> different "reply-to:" header.
>
> For instance, if I try to "Reply All" one of your messages, then
> Davis's address is included on the To: field but yours isn't.
> OTOH, if I "reply all" on Stefan's message, both you and Stefan will
> be included in the To field.

Ah, yes.  I use Gnus with its mailinglist mode in groups where
mailinglist messages are sorted to.  And then it generates a
Mail-Followup-To header so that I don't receive replies both via the
list and individually.  Well, that's usually what I want except in times
like now where no messages from emacs-devel seem to be delivered.  So
our mail clients work as intended.  Did you receive mail from
emacs-devel recently?

Bye,
Tassilo



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

* Re: [Emacs-diffs] master 188f657: Fix false negatives in tex--prettify-symbols-compose-p.
  2015-09-30 11:29                     ` Tassilo Horn
@ 2015-10-01  1:17                       ` Artur Malabarba
  2015-10-01 11:43                         ` Tassilo Horn
  0 siblings, 1 reply; 19+ messages in thread
From: Artur Malabarba @ 2015-10-01  1:17 UTC (permalink / raw)
  To: Artur Malabarba, emacs-devel

> Ah, yes.  I use Gnus with its mailinglist mode in groups where
> mailinglist messages are sorted to.  And then it generates a
> Mail-Followup-To header so that I don't receive replies both via the
> list and individually.  Well, that's usually what I want except in times
> like now where no messages from emacs-devel seem to be delivered.  So
> our mail clients work as intended.  Did you receive mail from
> emacs-devel recently?

If  "recently" means "in the last 24h", then yes. If it means a
shorter time span, then I'm not sure. :-)

Cheers,



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

* Re: [Emacs-diffs] master 188f657: Fix false negatives in tex--prettify-symbols-compose-p.
  2015-09-30 10:45                 ` Tassilo Horn
  2015-09-30 11:12                   ` Artur Malabarba
@ 2015-10-01  1:19                   ` Artur Malabarba
  2015-10-01 11:45                     ` Tassilo Horn
  1 sibling, 1 reply; 19+ messages in thread
From: Artur Malabarba @ 2015-10-01  1:19 UTC (permalink / raw)
  To: Artur Malabarba, emacs-devel, Tassilo Horn

>> Alright. I tested the code now and it works well. My only suggestion
>> would be to change this:
>>   (< (point) (car prettify-symbols--current-symbol-bounds))
>> to this:
>>   (<= (point) (car prettify-symbols--current-symbol-bounds))
>> But I guess that's more of a personal preference.
>
> Yes, I think so too.  But feel free to add that feature, e.g., by having
> another possibile value for `prettify-symbols-unprettify-at-point'.

Done!



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

* Re: [Emacs-diffs] master 188f657: Fix false negatives in tex--prettify-symbols-compose-p.
  2015-10-01  1:17                       ` Artur Malabarba
@ 2015-10-01 11:43                         ` Tassilo Horn
  0 siblings, 0 replies; 19+ messages in thread
From: Tassilo Horn @ 2015-10-01 11:43 UTC (permalink / raw)
  To: Artur Malabarba; +Cc: emacs-devel

Artur Malabarba <bruce.connor.am@gmail.com> writes:

>> Ah, yes.  I use Gnus with its mailinglist mode in groups where
>> mailinglist messages are sorted to.  And then it generates a
>> Mail-Followup-To header so that I don't receive replies both via the
>> list and individually.  Well, that's usually what I want except in
>> times like now where no messages from emacs-devel seem to be
>> delivered.  So our mail clients work as intended.  Did you receive
>> mail from emacs-devel recently?
>
> If  "recently" means "in the last 24h", then yes. If it means a
> shorter time span, then I'm not sure. :-)

Doesn't matter anymore.  It seems it started catching since today.

Bye,
Tassilo



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

* Re: [Emacs-diffs] master 188f657: Fix false negatives in tex--prettify-symbols-compose-p.
  2015-10-01  1:19                   ` Artur Malabarba
@ 2015-10-01 11:45                     ` Tassilo Horn
  0 siblings, 0 replies; 19+ messages in thread
From: Tassilo Horn @ 2015-10-01 11:45 UTC (permalink / raw)
  To: Artur Malabarba; +Cc: emacs-devel

Artur Malabarba <bruce.connor.am@gmail.com> writes:

>>> Alright. I tested the code now and it works well. My only suggestion
>>> would be to change this:
>>>   (< (point) (car prettify-symbols--current-symbol-bounds))
>>> to this:
>>>   (<= (point) (car prettify-symbols--current-symbol-bounds))
>>> But I guess that's more of a personal preference.
>>
>> Yes, I think so too.  But feel free to add that feature, e.g., by having
>> another possibile value for `prettify-symbols-unprettify-at-point'.
>
> Done!

After trying 'right-edge it turned out that I also prefer this
behavior. :-)

Thanks,
Tassilo



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

end of thread, other threads:[~2015-10-01 11:45 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20150925210512.18505.12538@vcs.savannah.gnu.org>
     [not found] ` <E1ZfaB6-0004p6-FL@vcs.savannah.gnu.org>
2015-09-26  4:54   ` [Emacs-diffs] master 188f657: Fix false negatives in tex--prettify-symbols-compose-p Stefan Monnier
2015-09-26  5:36     ` Tassilo Horn
2015-09-26  5:46       ` Tassilo Horn
2015-09-29 11:29   ` Artur Malabarba
2015-09-29 12:31     ` Tassilo Horn
2015-09-29 13:14       ` Artur Malabarba
2015-09-30  6:46         ` Tassilo Horn
2015-09-30  7:48           ` Artur Malabarba
     [not found]         ` <B393F5AD12955C48A84FFB08032CD04F6C218AED@ECS-EXG-P-MB01.win.lanl.gov>
2015-09-30  7:51           ` Artur Malabarba
2015-09-30  8:59             ` Tassilo Horn
2015-09-30 10:08               ` Artur Malabarba
2015-09-30 10:45                 ` Tassilo Horn
2015-09-30 11:12                   ` Artur Malabarba
2015-09-30 11:29                     ` Tassilo Horn
2015-10-01  1:17                       ` Artur Malabarba
2015-10-01 11:43                         ` Tassilo Horn
2015-10-01  1:19                   ` Artur Malabarba
2015-10-01 11:45                     ` Tassilo Horn
2015-09-29 19:46       ` Tassilo Horn

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.